mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-25 15:10:18 +01:00
Don't run confidence listeners if we get duplicate invs from the same peer (can happen if we connect to the same peer IP multiple times).
This commit is contained in:
parent
dfa722ccc8
commit
854d81eae9
2 changed files with 5 additions and 4 deletions
|
@ -268,8 +268,8 @@ public class MemoryPool {
|
||||||
private void markBroadcast(PeerAddress byPeer, Transaction tx) {
|
private void markBroadcast(PeerAddress byPeer, Transaction tx) {
|
||||||
checkState(lock.isHeldByCurrentThread());
|
checkState(lock.isHeldByCurrentThread());
|
||||||
final TransactionConfidence confidence = tx.getConfidence();
|
final TransactionConfidence confidence = tx.getConfidence();
|
||||||
confidence.markBroadcastBy(byPeer);
|
if (confidence.markBroadcastBy(byPeer))
|
||||||
confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS);
|
confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -274,12 +274,13 @@ public class TransactionConfidence implements Serializable {
|
||||||
*
|
*
|
||||||
* @param address IP address of the peer, used as a proxy for identity.
|
* @param address IP address of the peer, used as a proxy for identity.
|
||||||
*/
|
*/
|
||||||
public synchronized void markBroadcastBy(PeerAddress address) {
|
public synchronized boolean markBroadcastBy(PeerAddress address) {
|
||||||
if (!broadcastBy.addIfAbsent(address))
|
if (!broadcastBy.addIfAbsent(address))
|
||||||
return; // Duplicate.
|
return false; // Duplicate.
|
||||||
if (getConfidenceType() == ConfidenceType.UNKNOWN) {
|
if (getConfidenceType() == ConfidenceType.UNKNOWN) {
|
||||||
this.confidenceType = ConfidenceType.PENDING;
|
this.confidenceType = ConfidenceType.PENDING;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue