mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Refactor code for assigning address for better to make it more clear when we use the custom address and when the change address.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
658a01e5ae
commit
6a649416c2
@ -135,26 +135,32 @@ public class BurningManService {
|
||||
BurningManCandidate candidate = burningManCandidatesByName.get(name);
|
||||
|
||||
// Issuance
|
||||
compensationProposal.getBurningManReceiverAddress()
|
||||
.or(() -> daoStateService.getTx(compensationProposal.getTxId())
|
||||
.map(this::getAddressFromCompensationRequest))
|
||||
.ifPresent(address -> {
|
||||
int issuanceHeight = issuance.getChainHeight();
|
||||
long issuanceAmount = getIssuanceAmountForCompensationRequest(issuance);
|
||||
int cycleIndex = cyclesInDaoStateService.getCycleIndexAtChainHeight(issuanceHeight);
|
||||
if (isValidCompensationRequest(name, cycleIndex, issuanceAmount)) {
|
||||
long decayedIssuanceAmount = getDecayedCompensationAmount(issuanceAmount, issuanceHeight, chainHeight);
|
||||
long issuanceDate = daoStateService.getBlockTime(issuanceHeight);
|
||||
candidate.addCompensationModel(CompensationModel.fromCompensationRequest(address,
|
||||
issuanceAmount,
|
||||
decayedIssuanceAmount,
|
||||
issuanceHeight,
|
||||
issuance.getTxId(),
|
||||
issuanceDate,
|
||||
cycleIndex));
|
||||
}
|
||||
});
|
||||
|
||||
Optional<String> customAddress = compensationProposal.getBurningManReceiverAddress();
|
||||
boolean isCustomAddress = customAddress.isPresent();
|
||||
Optional<String> receiverAddress;
|
||||
if (isCustomAddress) {
|
||||
receiverAddress = customAddress;
|
||||
} else {
|
||||
// We take change address from compensation request
|
||||
receiverAddress = daoStateService.getTx(compensationProposal.getTxId())
|
||||
.map(this::getAddressFromCompensationRequest);
|
||||
}
|
||||
if (receiverAddress.isPresent()) {
|
||||
int issuanceHeight = issuance.getChainHeight();
|
||||
long issuanceAmount = getIssuanceAmountForCompensationRequest(issuance);
|
||||
int cycleIndex = cyclesInDaoStateService.getCycleIndexAtChainHeight(issuanceHeight);
|
||||
if (isValidCompensationRequest(name, cycleIndex, issuanceAmount)) {
|
||||
long decayedIssuanceAmount = getDecayedCompensationAmount(issuanceAmount, issuanceHeight, chainHeight);
|
||||
long issuanceDate = daoStateService.getBlockTime(issuanceHeight);
|
||||
candidate.addCompensationModel(CompensationModel.fromCompensationRequest(receiverAddress.get(),
|
||||
issuanceAmount,
|
||||
decayedIssuanceAmount,
|
||||
issuanceHeight,
|
||||
issuance.getTxId(),
|
||||
issuanceDate,
|
||||
cycleIndex));
|
||||
}
|
||||
}
|
||||
addBurnOutputModel(chainHeight, proofOfBurnOpReturnTxOutputByHash, name, candidate);
|
||||
});
|
||||
}
|
||||
@ -211,7 +217,7 @@ public class BurningManService {
|
||||
Set<BurningManCandidate> getActiveBurningManCandidates(int chainHeight) {
|
||||
return getBurningManCandidatesByName(chainHeight).values().stream()
|
||||
.filter(burningManCandidate -> burningManCandidate.getCappedBurnAmountShare() > 0)
|
||||
.filter(candidate -> candidate.getMostRecentAddress().isPresent())
|
||||
.filter(candidate -> candidate.getReceiverAddress().isPresent())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user