Skip to content

Commit

Permalink
Add txId to ProofOfBurnDto
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJannsen committed Jun 30, 2024
1 parent 7b85bc5 commit 444aa0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 5 additions & 3 deletions restapi/src/main/java/bisq/restapi/dto/ProofOfBurnDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
@Schema(title = "ProofOfBurn")
public class ProofOfBurnDto {
private final long amount;
private final long time;
private final long blockTime;
private final String hash;
private final int blockHeight;
private final String txId;

public ProofOfBurnDto(long amount, long time, String hash, int blockHeight) {
public ProofOfBurnDto(long amount, long blockTime, String hash, int blockHeight, String txId) {
this.amount = amount;
this.time = time;
this.blockTime = blockTime;
this.hash = hash;
this.blockHeight = blockHeight;
this.txId = txId;
}
}
17 changes: 12 additions & 5 deletions restapi/src/main/java/bisq/restapi/endpoints/ProofOfBurnApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ public List<ProofOfBurnDto> getProofOfBurn(@Parameter(description = DESC_BLOCK_H
@PathParam("block-height")
int fromBlockHeight) {
List<ProofOfBurnDto> result = daoStateService.getProofOfBurnTxs().stream()
.filter(tx -> tx.getBlockHeight() >= fromBlockHeight)
.map(tx -> new ProofOfBurnDto(tx.getBurntBsq(),
tx.getTime(),
Hex.encode(ProofOfBurnService.getHashFromOpReturnData(tx)),
tx.getBlockHeight()))
.filter(tx -> {
int blockHeight = tx.getBlockHeight();
return blockHeight >= fromBlockHeight;
})
.map(tx -> {
ProofOfBurnDto proofOfBurnDto = new ProofOfBurnDto(tx.getBurntBsq(),
tx.getTime(),
Hex.encode(ProofOfBurnService.getHashFromOpReturnData(tx)),
tx.getBlockHeight(),
tx.getId());
return proofOfBurnDto;
})
.collect(Collectors.toList());
log.info("ProofOfBurn result list from block height {}: {}", fromBlockHeight, result);
return result;
Expand Down

0 comments on commit 444aa0d

Please sign in to comment.