Republish only outside of voteReveal phase

This commit is contained in:
Manfred Karrer 2019-04-06 19:36:41 -05:00
parent 1df485a4fa
commit 419da79232
No known key found for this signature in database
GPG key ID: 401250966A6B2C46

View file

@ -135,7 +135,7 @@ public class MyBlindVoteListService implements PersistedDataHost, DaoStateListen
this.myVoteListService = myVoteListService;
this.myProposalListService = myProposalListService;
numConnectedPeersListener = (observable, oldValue, newValue) -> rePublishMyBlindVoteOnceWellConnected();
numConnectedPeersListener = (observable, oldValue, newValue) -> maybeRePublishMyBlindVote();
}
@ -176,7 +176,7 @@ public class MyBlindVoteListService implements PersistedDataHost, DaoStateListen
@Override
public void onParseBlockChainComplete() {
rePublishMyBlindVoteOnceWellConnected();
maybeRePublishMyBlindVote();
}
@ -351,7 +351,14 @@ public class MyBlindVoteListService implements PersistedDataHost, DaoStateListen
return bsqWalletService.signTx(txWithBtcFee);
}
private void rePublishMyBlindVoteOnceWellConnected() {
private void maybeRePublishMyBlindVote() {
// We do not republish during vote reveal phase as peer would reject blindVote data to protect against
// late publishing attacks.
// This attack is only relevant during the vote reveal phase as there it could cause damage by disturbing the
// data view of the blind votes of the voter for creating the majority hash.
// To republish after the vote reveal phase still makes sense to reduce risk that some nodes have not received
// it and would need to request the data then in the vote result phase.
if (!periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.VOTE_REVEAL)) {
// We republish at each startup at any block during the cycle. We filter anyway for valid blind votes
// of that cycle so it is 1 blind vote getting rebroadcast at each startup to my neighbors.
// Republishing only will have effect if the payload creation date is < 5 hours as other nodes would not
@ -370,6 +377,7 @@ public class MyBlindVoteListService implements PersistedDataHost, DaoStateListen
UserThread.execute(() -> p2PService.getNumConnectedPeers().removeListener(numConnectedPeersListener));
}
}
}
private void addToP2PNetwork(BlindVote blindVote, @Nullable ErrorMessageHandler errorMessageHandler) {
BlindVotePayload blindVotePayload = new BlindVotePayload(blindVote);