mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 23:32:16 +00:00
Fix a race condition in the memory pool code. Update issue 353.
This commit is contained in:
parent
8b437eaf95
commit
0548e983ed
@ -200,13 +200,14 @@ public class MemoryPool {
|
||||
entry.tx = new WeakTransactionReference(tx, referenceQueue);
|
||||
Set<PeerAddress> addrs = entry.addresses;
|
||||
entry.addresses = null;
|
||||
// Copy the previously announced peers into the confidence and then clear it out. Unlock here
|
||||
// because markBroadcastBy can trigger event listeners and thus inversions.
|
||||
TransactionConfidence confidence = tx.getConfidence();
|
||||
log.debug("{}: Adding tx [{}] {} to the memory pool",
|
||||
new Object[]{byPeer, confidence.numBroadcastPeers(), tx.getHashAsString()});
|
||||
lock.unlock();
|
||||
// Copy the previously announced peers into the confidence and then clear it out. Unlock here
|
||||
// because markBroadcastBy can trigger event listeners and thus inversions. After the lock is
|
||||
// released "entry" may be changing arbitrarily and isn't usable.
|
||||
skipUnlock = true;
|
||||
lock.unlock();
|
||||
for (PeerAddress a : addrs) {
|
||||
confidence.markBroadcastBy(a);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user