3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 10:15:52 +00:00

TransactionBroadcast: when there are an odd number of peers, bias towards more receivers rather than more announcers.

This commit is contained in:
Mike Hearn 2013-11-20 14:53:17 +01:00
parent 2bca8e858b
commit 62078f55c0

View File

@ -97,7 +97,7 @@ public class TransactionBroadcast {
// our version message, as SPV nodes cannot relay it doesn't give away any additional information
// to skip the inv here - we wouldn't send invs anyway.
int numConnected = peers.size();
numToBroadcastTo = Math.max(1, peers.size() / 2);
numToBroadcastTo = (int) Math.max(1, Math.round(Math.ceil(peers.size() / 2.0)));
numWaitingFor = (int) Math.ceil((peers.size() - numToBroadcastTo) / 2.0);
Collections.shuffle(peers, random);
peers = peers.subList(0, numToBroadcastTo);