Skip to content

Commit

Permalink
Merge pull request #2377 from ManfredKarrer/dao-fix-remove-proposal-h…
Browse files Browse the repository at this point in the history
…andling

Fix missing removal of old or invalid proposals
  • Loading branch information
ManfredKarrer authored Feb 11, 2019
2 parents 12d2879 + df0a8b7 commit f87522f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,23 @@ private void onProtectedDataRemoved(ProtectedStorageEntry entry) {
if (protectedStoragePayload instanceof TempProposalPayload) {
Proposal proposal = ((TempProposalPayload) protectedStoragePayload).getProposal();
// We allow removal only if we are in the proposal phase.
if (periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL)) {
boolean inPhase = periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL);
boolean txInPastCycle = periodService.isTxInPastCycle(proposal.getTxId(), daoStateService.getChainHeight());
Optional<Tx> tx = daoStateService.getTx(proposal.getTxId());
boolean unconfirmedOrNonBsqTx = !tx.isPresent();
// if the tx is unconfirmed we need to be in the PROPOSAL phase, otherwise the tx must be confirmed.
if (inPhase || txInPastCycle || unconfirmedOrNonBsqTx) {
if (tempProposals.contains(proposal)) {
log.info("We received a remove request for a TempProposalPayload and have removed the proposal " +
"from our list. proposalTxId={}", proposal.getTxId());
tempProposals.remove(proposal);
log.info("We received a remove request for a TempProposalPayload and have removed the proposal " +
"from our list. proposal creation date={}, proposalTxId={}, inPhase={}, " +
"txInPastCycle={}, unconfirmedOrNonBsqTx={}",
proposal.getCreationDate(), proposal.getTxId(), inPhase, txInPastCycle, unconfirmedOrNonBsqTx);
}
} else {
Optional<Tx> tx = daoStateService.getTx(proposal.getTxId());
log.warn("We received a remove request outside the PROPOSAL phase. " +
"Proposal.txId={}, current blockHeight={}, tx blockHeight={}, proposal creation date={}",
proposal.getTxId(), daoStateService.getChainHeight(),
tx.isPresent() ? tx.get().getBlockHeight() : "null", proposal.getCreationDate());
"Proposal creation date={}, proposal.txId={}, current blockHeight={}",
proposal.getCreationDate(), proposal.getTxId(), daoStateService.getChainHeight());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ private void revealVote(MyVote myVote, boolean inBlindVotePhase) {
// If we are not in the right phase we just add an empty hash (still need to have the hash as otherwise we
// would not recognize the tx as vote reveal tx)
byte[] hashOfBlindVoteList = inBlindVotePhase ? getHashOfBlindVoteList() : new byte[20];
log.info("revealVote: Sha256Ripemd160 hash of hashOfBlindVoteList " + Utilities.bytesAsHexString(hashOfBlindVoteList));
byte[] opReturnData = VoteRevealConsensus.getOpReturnData(hashOfBlindVoteList, myVote.getSecretKey());

// We search for my unspent stake output.
Expand Down

0 comments on commit f87522f

Please sign in to comment.