mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Improve logs. Add ToString annotation
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
e4cdfa731a
commit
cb25660b68
@ -18,6 +18,7 @@
|
|||||||
package bisq.daonode.dto;
|
package bisq.daonode.dto;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ToString
|
||||||
@Schema(title = "BondedReputation")
|
@Schema(title = "BondedReputation")
|
||||||
public class BondedReputationDto {
|
public class BondedReputationDto {
|
||||||
private final long amount;
|
private final long amount;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package bisq.daonode.dto;
|
package bisq.daonode.dto;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
* Need to be in sync with the Bisq 2 ProofOfBurnDto class.
|
* Need to be in sync with the Bisq 2 ProofOfBurnDto class.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
@ToString
|
||||||
@Schema(title = "ProofOfBurn")
|
@Schema(title = "ProofOfBurn")
|
||||||
public class ProofOfBurnDto {
|
public class ProofOfBurnDto {
|
||||||
private final long amount;
|
private final long amount;
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
package bisq.daonode.endpoints;
|
package bisq.daonode.endpoints;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitness;
|
import bisq.core.account.witness.AccountAgeWitness;
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -54,9 +57,11 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class AccountAgeApi {
|
public class AccountAgeApi {
|
||||||
private static final String DESC_HASH = "The hash of the account age witness as hex string";
|
private static final String DESC_HASH = "The hash of the account age witness as hex string";
|
||||||
private final RestApi restApi;
|
private final RestApi restApi;
|
||||||
|
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||||
|
|
||||||
public AccountAgeApi(@Context Application application) {
|
public AccountAgeApi(@Context Application application) {
|
||||||
restApi = ((RestApiMain) application).getRestApi();
|
restApi = ((RestApiMain) application).getRestApi();
|
||||||
|
accountAgeWitnessService = checkNotNull(restApi.getAccountAgeWitnessService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(description = "Request the account age date")
|
@Operation(description = "Request the account age date")
|
||||||
@ -69,8 +74,10 @@ public class AccountAgeApi {
|
|||||||
public Long getDate(@Parameter(description = DESC_HASH)
|
public Long getDate(@Parameter(description = DESC_HASH)
|
||||||
@PathParam("hash")
|
@PathParam("hash")
|
||||||
String hash) {
|
String hash) {
|
||||||
return checkNotNull(restApi.getAccountAgeWitnessService()).getWitnessByHashAsHex(hash)
|
long result = accountAgeWitnessService.getWitnessByHashAsHex(hash)
|
||||||
.map(AccountAgeWitness::getDate)
|
.map(AccountAgeWitness::getDate)
|
||||||
.orElse(-1L);
|
.orElse(-1L);
|
||||||
|
log.info("Account age for hash {}: {} ({})", hash, result, new Date(result));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class BondedReputationApi {
|
|||||||
@PathParam("block-height")
|
@PathParam("block-height")
|
||||||
int fromBlockHeight) {
|
int fromBlockHeight) {
|
||||||
// We only consider lock time with at least 50 000 blocks as valid
|
// We only consider lock time with at least 50 000 blocks as valid
|
||||||
return bondedReputationRepository.getActiveBonds().stream()
|
List<BondedReputationDto> result = bondedReputationRepository.getActiveBonds().stream()
|
||||||
.filter(bondedReputation -> bondedReputation.getLockTime() >= 50_000)
|
.filter(bondedReputation -> bondedReputation.getLockTime() >= 50_000)
|
||||||
.map(bondedReputation -> {
|
.map(bondedReputation -> {
|
||||||
Optional<Tx> optionalTx = daoStateService.getTx(bondedReputation.getLockupTxId());
|
Optional<Tx> optionalTx = daoStateService.getTx(bondedReputation.getLockupTxId());
|
||||||
@ -102,5 +102,8 @@ public class BondedReputationApi {
|
|||||||
})
|
})
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
log.info("BondedReputation result list from block height {}: {}", fromBlockHeight, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package bisq.daonode.endpoints;
|
package bisq.daonode.endpoints;
|
||||||
|
|
||||||
import bisq.core.dao.governance.proofofburn.ProofOfBurnService;
|
import bisq.core.dao.governance.proofofburn.ProofOfBurnService;
|
||||||
|
import bisq.core.dao.state.DaoStateService;
|
||||||
|
|
||||||
import bisq.common.util.Hex;
|
import bisq.common.util.Hex;
|
||||||
|
|
||||||
@ -58,10 +59,11 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
@Tag(name = "Proof of burn API")
|
@Tag(name = "Proof of burn API")
|
||||||
public class ProofOfBurnApi {
|
public class ProofOfBurnApi {
|
||||||
private static final String DESC_BLOCK_HEIGHT = "The block height from which we request the proof of burn data";
|
private static final String DESC_BLOCK_HEIGHT = "The block height from which we request the proof of burn data";
|
||||||
private final RestApi restApi;
|
private final DaoStateService daoStateService;
|
||||||
|
|
||||||
public ProofOfBurnApi(@Context Application application) {
|
public ProofOfBurnApi(@Context Application application) {
|
||||||
restApi = ((RestApiMain) application).getRestApi();
|
RestApi restApi = ((RestApiMain) application).getRestApi();
|
||||||
|
daoStateService = checkNotNull(restApi.getDaoStateService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(description = "Request the proof of burn data")
|
@Operation(description = "Request the proof of burn data")
|
||||||
@ -74,12 +76,14 @@ public class ProofOfBurnApi {
|
|||||||
public List<ProofOfBurnDto> getProofOfBurn(@Parameter(description = DESC_BLOCK_HEIGHT)
|
public List<ProofOfBurnDto> getProofOfBurn(@Parameter(description = DESC_BLOCK_HEIGHT)
|
||||||
@PathParam("block-height")
|
@PathParam("block-height")
|
||||||
int fromBlockHeight) {
|
int fromBlockHeight) {
|
||||||
return checkNotNull(restApi.getDaoStateService()).getProofOfBurnTxs().stream()
|
List<ProofOfBurnDto> result = daoStateService.getProofOfBurnTxs().stream()
|
||||||
.filter(tx -> tx.getBlockHeight() >= fromBlockHeight)
|
.filter(tx -> tx.getBlockHeight() >= fromBlockHeight)
|
||||||
.map(tx -> new ProofOfBurnDto(tx.getBurntBsq(),
|
.map(tx -> new ProofOfBurnDto(tx.getBurntBsq(),
|
||||||
tx.getTime(),
|
tx.getTime(),
|
||||||
Hex.encode(ProofOfBurnService.getHashFromOpReturnData(tx)),
|
Hex.encode(ProofOfBurnService.getHashFromOpReturnData(tx)),
|
||||||
tx.getBlockHeight()))
|
tx.getBlockHeight()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
log.info("ProofOfBurn result list from block height {}: {}", fromBlockHeight, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package bisq.daonode.endpoints;
|
|||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -53,10 +55,11 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
@Tag(name = "Signed witness API")
|
@Tag(name = "Signed witness API")
|
||||||
public class SignedWitnessApi {
|
public class SignedWitnessApi {
|
||||||
private static final String DESC_HASH = "The hash of the signed account age witness as hex string";
|
private static final String DESC_HASH = "The hash of the signed account age witness as hex string";
|
||||||
private final RestApi restApi;
|
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||||
|
|
||||||
public SignedWitnessApi(@Context Application application) {
|
public SignedWitnessApi(@Context Application application) {
|
||||||
restApi = ((RestApiMain) application).getRestApi();
|
RestApi restApi = ((RestApiMain) application).getRestApi();
|
||||||
|
accountAgeWitnessService = checkNotNull(restApi.getAccountAgeWitnessService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(description = "Request the signed witness date")
|
@Operation(description = "Request the signed witness date")
|
||||||
@ -69,9 +72,10 @@ public class SignedWitnessApi {
|
|||||||
public Long getDate(@Parameter(description = DESC_HASH)
|
public Long getDate(@Parameter(description = DESC_HASH)
|
||||||
@PathParam("hash")
|
@PathParam("hash")
|
||||||
String hash) {
|
String hash) {
|
||||||
AccountAgeWitnessService accountAgeWitnessService = checkNotNull(restApi.getAccountAgeWitnessService());
|
long result = accountAgeWitnessService.getWitnessByHashAsHex(hash)
|
||||||
return accountAgeWitnessService.getWitnessByHashAsHex(hash)
|
|
||||||
.map(accountAgeWitnessService::getWitnessSignDate)
|
.map(accountAgeWitnessService::getWitnessSignDate)
|
||||||
.orElse(-1L);
|
.orElse(-1L);
|
||||||
|
log.info("SignedWitness sign date for hash {}: {} ({})", hash, result, new Date(result));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user