@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (getDepthInBlocks() >= depth) { removeEventListener(this); result.set(confidence); } } });
@Override public void onConfidenceChanged(TransactionConfidence conf, ChangeReason reason) { // The number of peers that announced this tx has gone up. int numSeenPeers = conf.numBroadcastPeers() + rejects.size(); boolean mined = tx.getAppearsInHashes() != null; log.info("broadcastTransaction: {}: TX {} seen by {} peers{}", reason, tx.getHashAsString(), numSeenPeers, mined ? " and mined" : ""); // Progress callback on the requested thread. invokeAndRecord(numSeenPeers, mined); if (numSeenPeers >= numWaitingFor || mined) { // We've seen the min required number of peers announce the transaction, or it was included // in a block. Normally we'd expect to see it fully propagate before it gets mined, but // it can be that a block is solved very soon after broadcast, and it's also possible that // due to version skew and changes in the relay rules our transaction is not going to // fully propagate yet can get mined anyway. // // Note that we can't wait for the current number of connected peers right now because we // could have added more peers after the broadcast took place, which means they won't // have seen the transaction. In future when peers sync up their memory pools after they // connect we could come back and change this. // // We're done! It's important that the PeerGroup lock is not held (by this thread) at this // point to avoid triggering inversions when the Future completes. log.info("broadcastTransaction: {} complete", tx.getHash()); peerGroup.removePreMessageReceivedEventListener(rejectionListener); conf.removeEventListener(this); future.set(tx); // RE-ENTRANCY POINT } } }
@Override public void onConfidenceChanged(TransactionConfidence conf, ChangeReason reason) { // The number of peers that announced this tx has gone up. int numSeenPeers = conf.numBroadcastPeers() + rejects.size(); boolean mined = tx.getAppearsInHashes() != null; log.info("broadcastTransaction: {}: TX {} seen by {} peers{}", reason, tx.getHashAsString(), numSeenPeers, mined ? " and mined" : ""); // Progress callback on the requested thread. invokeAndRecord(numSeenPeers, mined); if (numSeenPeers >= numWaitingFor || mined) { // We've seen the min required number of peers announce the transaction, or it was included // in a block. Normally we'd expect to see it fully propagate before it gets mined, but // it can be that a block is solved very soon after broadcast, and it's also possible that // due to version skew and changes in the relay rules our transaction is not going to // fully propagate yet can get mined anyway. // // Note that we can't wait for the current number of connected peers right now because we // could have added more peers after the broadcast took place, which means they won't // have seen the transaction. In future when peers sync up their memory pools after they // connect we could come back and change this. // // We're done! It's important that the PeerGroup lock is not held (by this thread) at this // point to avoid triggering inversions when the Future completes. log.info("broadcastTransaction: {} complete", tx.getHash()); peerGroup.removePreMessageReceivedEventListener(rejectionListener); conf.removeEventListener(this); future.set(tx); // RE-ENTRANCY POINT } } }
@Override public void onConfidenceChanged(TransactionConfidence conf, ChangeReason reason) { // The number of peers that announced this tx has gone up. int numSeenPeers = conf.numBroadcastPeers() + rejects.size(); boolean mined = tx.getAppearsInHashes() != null; log.info("broadcastTransaction: {}: TX {} seen by {} peers{}", reason, tx.getHashAsString(), numSeenPeers, mined ? " and mined" : ""); // Progress callback on the requested thread. invokeAndRecord(numSeenPeers, mined); if (numSeenPeers >= numWaitingFor || mined) { // We've seen the min required number of peers announce the transaction, or it was included // in a block. Normally we'd expect to see it fully propagate before it gets mined, but // it can be that a block is solved very soon after broadcast, and it's also possible that // due to version skew and changes in the relay rules our transaction is not going to // fully propagate yet can get mined anyway. // // Note that we can't wait for the current number of connected peers right now because we // could have added more peers after the broadcast took place, which means they won't // have seen the transaction. In future when peers sync up their memory pools after they // connect we could come back and change this. // // We're done! It's important that the PeerGroup lock is not held (by this thread) at this // point to avoid triggering inversions when the Future completes. log.info("broadcastTransaction: {} complete", tx.getHash()); peerGroup.removePreMessageReceivedEventListener(rejectionListener); conf.removeEventListener(this); future.set(tx); // RE-ENTRANCY POINT } } }
@Override public void onConfidenceChanged(TransactionConfidence conf, ChangeReason reason) { // The number of peers that announced this tx has gone up. int numSeenPeers = conf.numBroadcastPeers() + rejects.size(); boolean mined = tx.getAppearsInHashes() != null; log.info("broadcastTransaction: {}: TX {} seen by {} peers{}", reason, tx.getHashAsString(), numSeenPeers, mined ? " and mined" : ""); // Progress callback on the requested thread. invokeAndRecord(numSeenPeers, mined); if (numSeenPeers >= numWaitingFor || mined) { // We've seen the min required number of peers announce the transaction, or it was included // in a block. Normally we'd expect to see it fully propagate before it gets mined, but // it can be that a block is solved very soon after broadcast, and it's also possible that // due to version skew and changes in the relay rules our transaction is not going to // fully propagate yet can get mined anyway. // // Note that we can't wait for the current number of connected peers right now because we // could have added more peers after the broadcast took place, which means they won't // have seen the transaction. In future when peers sync up their memory pools after they // connect we could come back and change this. // // We're done! It's important that the PeerGroup lock is not held (by this thread) at this // point to avoid triggering inversions when the Future completes. log.info("broadcastTransaction: {} complete", tx.getHash()); peerGroup.removePreMessageReceivedEventListener(rejectionListener); conf.removeEventListener(this); future.set(tx); // RE-ENTRANCY POINT } } }
@Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { if (reason.equals(ChangeReason.TYPE)) { if (confidence.getConfidenceType().equals(ConfidenceType.PENDING)) { processPendingTransactions(tx); // Continue tracking the transaction. } else if (confidence.getConfidenceType().equals(ConfidenceType.BUILDING)) { processBuildingTransaction(tx); // Continue tracking the transaction for confirmation. } else if (confidence.getConfidenceType().equals(DEAD)) { // Stop tracking the transaction. tx.getBitcoinjTransaction().getConfidence().removeEventListener(this); } } else if (reason.equals(ChangeReason.DEPTH)) { if (confidence.getDepthInBlocks() >= configHolder.getBitcoinConfirmationBlockdepth()) { confirmTransaction(tx); tx.getBitcoinjTransaction().getConfidence().removeEventListener(this); } } } });