3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00: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:
Mike Hearn 2013-10-14 12:05:18 +02:00
parent dfa722ccc8
commit 854d81eae9
2 changed files with 5 additions and 4 deletions

View File

@ -268,8 +268,8 @@ public class MemoryPool {
private void markBroadcast(PeerAddress byPeer, Transaction tx) {
checkState(lock.isHeldByCurrentThread());
final TransactionConfidence confidence = tx.getConfidence();
confidence.markBroadcastBy(byPeer);
confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS);
if (confidence.markBroadcastBy(byPeer))
confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS);
}
/**

View File

@ -274,12 +274,13 @@ public class TransactionConfidence implements Serializable {
*
* @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))
return; // Duplicate.
return false; // Duplicate.
if (getConfidenceType() == ConfidenceType.UNKNOWN) {
this.confidenceType = ConfidenceType.PENDING;
}
return true;
}
/**