3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

Wallet: don't crash if receivePending is called twice with the same tx, even if the override flag is on.

This commit is contained in:
Mike Hearn 2013-07-24 16:17:47 +02:00
parent 51d717e93a
commit 9e78268813

View File

@ -647,6 +647,13 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
lock.lock(); lock.lock();
try { try {
tx.verify(); tx.verify();
// Ignore it if we already know about this transaction. Receiving a pending transaction never moves it
// between pools.
EnumSet<Pool> containingPools = getContainingPools(tx);
if (!containingPools.equals(EnumSet.noneOf(Pool.class))) {
log.debug("Received tx we already saw in a block or created ourselves: " + tx.getHashAsString());
return;
}
// Repeat the check of relevancy here, even though the caller may have already done so - this is to avoid // Repeat the check of relevancy here, even though the caller may have already done so - this is to avoid
// race conditions where receivePending may be being called in parallel. // race conditions where receivePending may be being called in parallel.
if (!overrideIsRelevant && !isPendingTransactionRelevant(tx)) if (!overrideIsRelevant && !isPendingTransactionRelevant(tx))
@ -691,7 +698,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
receivePending(tx, dependencies, false); receivePending(tx, dependencies, false);
} }
private static AnalysisResult analyzeTransactionAndDependencies(Transaction tx, List<Transaction> dependencies) { private static AnalysisResult analyzeTransactionAndDependencies(Transaction tx, @Nullable List<Transaction> dependencies) {
AnalysisResult result = new AnalysisResult(); AnalysisResult result = new AnalysisResult();
if (tx.isTimeLocked()) if (tx.isTimeLocked())
result.timeLocked = tx; result.timeLocked = tx;