mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
TransactionBroadcast: extract method dropPeerAfterBroadcastHandler(Peer)
Refactor the creation of this lambda to its own method.
This commit is contained in:
parent
81fd758800
commit
419dba9845
1 changed files with 8 additions and 4 deletions
|
@ -212,10 +212,7 @@ public class TransactionBroadcast {
|
||||||
if (dropPeersAfterBroadcast) {
|
if (dropPeersAfterBroadcast) {
|
||||||
// We drop the peer shortly after the transaction has been sent, because this peer will not
|
// We drop the peer shortly after the transaction has been sent, because this peer will not
|
||||||
// send us back useful broadcast confirmations.
|
// send us back useful broadcast confirmations.
|
||||||
future.thenRunAsync(() -> {
|
future.thenRunAsync(dropPeerAfterBroadcastHandler(peer), Threading.THREAD_POOL);
|
||||||
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
|
|
||||||
peer.close();
|
|
||||||
}, Threading.THREAD_POOL);
|
|
||||||
}
|
}
|
||||||
// We don't record the peer as having seen the tx in the memory pool because we want to track only
|
// We don't record the peer as having seen the tx in the memory pool because we want to track only
|
||||||
// how many peers announced to us.
|
// how many peers announced to us.
|
||||||
|
@ -226,6 +223,13 @@ public class TransactionBroadcast {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Runnable dropPeerAfterBroadcastHandler(Peer peer) {
|
||||||
|
return () -> {
|
||||||
|
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
|
||||||
|
peer.close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomly choose a subset of connected peers to broadcast to
|
* Randomly choose a subset of connected peers to broadcast to
|
||||||
* @param connectedPeers connected peers to chose from
|
* @param connectedPeers connected peers to chose from
|
||||||
|
|
Loading…
Add table
Reference in a new issue