3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-16 04:05:50 +00:00

PeerGroup: add logging of the change reason to the broadcast confidence listener. Also attach the listener to the pinned TX (it shouldn't make any difference normally, but when mixed with bluetooth stuff it might possibly change things).

This commit is contained in:
Mike Hearn 2013-10-27 15:37:06 +01:00
parent 387717c6c5
commit 9d96f77f19

View File

@ -1197,14 +1197,14 @@ public class PeerGroup extends AbstractIdleService implements TransactionBroadca
final Transaction pinnedTx = memoryPool.seen(tx, somePeer.getAddress()); final Transaction pinnedTx = memoryPool.seen(tx, somePeer.getAddress());
// Prepare to send the transaction by adding a listener that'll be called when confidence changes. // Prepare to send the transaction by adding a listener that'll be called when confidence changes.
// Only bother with this if we might actually hear back: // Only bother with this if we might actually hear back:
if (minConnections > 1) tx.getConfidence().addEventListener(new TransactionConfidence.Listener() { if (minConnections > 1) pinnedTx.getConfidence().addEventListener(new TransactionConfidence.Listener() {
public void onConfidenceChanged(Transaction tx, TransactionConfidence.Listener.ChangeReason reason) { public void onConfidenceChanged(Transaction tx, TransactionConfidence.Listener.ChangeReason reason) {
// The number of peers that announced this tx has gone up. // The number of peers that announced this tx has gone up.
final TransactionConfidence conf = tx.getConfidence(); final TransactionConfidence conf = tx.getConfidence();
int numSeenPeers = conf.numBroadcastPeers(); int numSeenPeers = conf.numBroadcastPeers();
boolean mined = tx.getAppearsInHashes() != null; boolean mined = tx.getAppearsInHashes() != null;
log.info("broadcastTransaction: TX {} seen by {} peers{}", log.info("broadcastTransaction: {}: TX {} seen by {} peers{}", reason, pinnedTx.getHashAsString(),
new Object[]{pinnedTx.getHashAsString(), numSeenPeers, mined ? " and mined" : ""}); numSeenPeers, mined ? " and mined" : "");
if (!(numSeenPeers >= minConnections || mined)) if (!(numSeenPeers >= minConnections || mined))
return; return;
// We've seen the min required number of peers announce the transaction, or it was included // We've seen the min required number of peers announce the transaction, or it was included