PeerGroup: Only drop peers after broadcast if the transaction has no broadcast confirmations.
Otherwise, peers might be continuously dropped when transactions are re-sent.
@@ -2042,8 +2042,8 @@ public class PeerGroup implements TransactionBroadcaster {
/**
* Calls {@link PeerGroup#broadcastTransaction(Transaction, int, boolean)} with getMinBroadcastConnections() as
- * the number of connections to wait for before commencing broadcast. Also, broadcast peers will be dropped after
- * the transaction has been sent.
+ * the number of connections to wait for before commencing broadcast. Also, if the transaction has no broadcast
+ * confirmations yet the peers will be dropped after the transaction has been sent.
*/
@Override
public TransactionBroadcast broadcastTransaction(final Transaction tx) {
@@ -2058,6 +2058,9 @@ public class PeerGroup implements TransactionBroadcaster {
* {@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the
* result.</p>
*
+ * <p>Optionally, peers will be dropped after they have been used for broadcasting the transaction and they have
+ * no broadcast confirmations yet.</p>
+ *
* <p>Note that if the PeerGroup is limited to only one connection (discovery is not activated) then the future
* will complete as soon as the transaction was successfully written to that peer.</p>
*
@@ -2078,7 +2081,7 @@ public class PeerGroup implements TransactionBroadcaster {
}
final TransactionBroadcast broadcast = new TransactionBroadcast(this, tx);
broadcast.setMinConnections(minConnections);
- broadcast.setDropPeersAfterBroadcast(dropPeersAfterBroadcast);
+ broadcast.setDropPeersAfterBroadcast(dropPeersAfterBroadcast && tx.getConfidence().numBroadcastPeers() == 0);
// Send the TX to the wallet once we have a successful broadcast.
Futures.addCallback(broadcast.future(), new FutureCallback<Transaction>() {
@Override
