use of bisq.core.dao.blockchain.ReadableBsqBlockChain in project bisq-core by bisq-network.
the class IssuanceConsensus method applyVoteResult.
public static void applyVoteResult(Map<Proposal, Integer> stakeByProposalMap, ReadableBsqBlockChain readableBsqBlockChain, WritableBsqBlockChain writableBsqBlockChain) {
Map<String, TxOutput> txOutputsByTxIdMap = new HashMap<>();
final Set<TxOutput> compReqIssuanceTxOutputs = readableBsqBlockChain.getCompReqIssuanceTxOutputs();
compReqIssuanceTxOutputs.stream().filter(// our candidate is not yet verified and not set
txOutput -> !txOutput.isVerified()).forEach(txOutput -> txOutputsByTxIdMap.put(txOutput.getTxId(), txOutput));
stakeByProposalMap.forEach((proposal, value) -> {
int stakeResult = value;
if (stakeResult >= QUORUM) {
final String txId = proposal.getTxId();
if (txOutputsByTxIdMap.containsKey(txId)) {
final TxOutput txOutput = txOutputsByTxIdMap.get(txId);
writableBsqBlockChain.issueBsq(txOutput);
log.info("We issued new BSQ to txOutput {} for proposal {}", txOutput, proposal);
}
} else {
log.warn("We got a successful vote result but did not reach the quorum. stake={}, quorum={}", stakeResult, QUORUM);
}
});
}
Aggregations