mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add new methods to DaoStateService and DaoFacade.
Will be used later by BurningMan domain. Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
5c7a3308a7
commit
ea5662f84d
@ -53,6 +53,7 @@ import bisq.core.dao.governance.proposal.reimbursement.ReimbursementConsensus;
|
||||
import bisq.core.dao.governance.proposal.reimbursement.ReimbursementProposalFactory;
|
||||
import bisq.core.dao.governance.proposal.removeAsset.RemoveAssetProposalFactory;
|
||||
import bisq.core.dao.governance.proposal.role.RoleProposalFactory;
|
||||
import bisq.core.dao.governance.proposal.storage.appendonly.ProposalPayload;
|
||||
import bisq.core.dao.monitoring.DaoStateMonitoringService;
|
||||
import bisq.core.dao.state.DaoStateListener;
|
||||
import bisq.core.dao.state.DaoStateService;
|
||||
@ -65,8 +66,10 @@ import bisq.core.dao.state.model.blockchain.TxOutputKey;
|
||||
import bisq.core.dao.state.model.blockchain.TxType;
|
||||
import bisq.core.dao.state.model.governance.Ballot;
|
||||
import bisq.core.dao.state.model.governance.BondedRoleType;
|
||||
import bisq.core.dao.state.model.governance.CompensationProposal;
|
||||
import bisq.core.dao.state.model.governance.Cycle;
|
||||
import bisq.core.dao.state.model.governance.DaoPhase;
|
||||
import bisq.core.dao.state.model.governance.Issuance;
|
||||
import bisq.core.dao.state.model.governance.IssuanceType;
|
||||
import bisq.core.dao.state.model.governance.Proposal;
|
||||
import bisq.core.dao.state.model.governance.Role;
|
||||
@ -646,6 +649,24 @@ public class DaoFacade implements DaoSetupService {
|
||||
return daoStateService.getIssuanceSetForType(issuanceType).size();
|
||||
}
|
||||
|
||||
public Set<Issuance> getIssuanceSetForType(IssuanceType issuanceType) {
|
||||
return daoStateService.getIssuanceSetForType(issuanceType);
|
||||
}
|
||||
|
||||
public Map<TxOutputKey, Optional<String>> getAddressByOutputKeyMap() {
|
||||
return daoStateService.getUnorderedTxOutputStream()
|
||||
.collect(Collectors.toMap(BaseTxOutput::getKey, txOutput -> Optional.ofNullable(txOutput.getAddress())));
|
||||
}
|
||||
|
||||
public Optional<CompensationProposal> findCompensationProposal(String txId) {
|
||||
return proposalService.getProposalPayloads().stream()
|
||||
.map(ProposalPayload::getProposal)
|
||||
.filter(proposal -> txId.equals(proposal.getTxId()))
|
||||
.filter(proposal -> proposal instanceof CompensationProposal)
|
||||
.map(proposal -> (CompensationProposal) proposal)
|
||||
.findAny();
|
||||
}
|
||||
|
||||
public Set<Tx> getBurntFeeTxs() {
|
||||
return daoStateService.getBurntFeeTxs();
|
||||
}
|
||||
|
@ -201,6 +201,28 @@ public class DaoStateService implements DaoSetupService {
|
||||
return getCycle(blockHeight).map(cycle -> cycle.getHeightOfFirstBlock());
|
||||
}
|
||||
|
||||
public Optional<Cycle> getNextCycle(Cycle cycle) {
|
||||
return getCycle(cycle.getHeightOfLastBlock() + 1);
|
||||
}
|
||||
|
||||
public Optional<Cycle> getPreviousCycle(Cycle cycle) {
|
||||
return getCycle(cycle.getHeightOfFirstBlock() - 1);
|
||||
}
|
||||
|
||||
public Optional<Cycle> getPastCycle(Cycle cycle, int numPastCycles) {
|
||||
Optional<Cycle> previous = Optional.empty();
|
||||
Cycle current = cycle;
|
||||
for (int i = 0; i < numPastCycles; i++) {
|
||||
previous = getPreviousCycle(current);
|
||||
if (previous.isPresent()) {
|
||||
current = previous.get();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return previous;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Block
|
||||
@ -440,7 +462,7 @@ public class DaoStateService implements DaoSetupService {
|
||||
// TxOutput
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private Stream<TxOutput> getUnorderedTxOutputStream() {
|
||||
public Stream<TxOutput> getUnorderedTxOutputStream() {
|
||||
return getUnorderedTxStream()
|
||||
.flatMap(tx -> tx.getTxOutputs().stream());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user