Return false when calling Chain.add on an orphan we already have

This commit is contained in:
Matt Corallo 2012-08-29 22:05:03 -04:00 committed by Mike Hearn
parent 599d4a671c
commit f3d9c02841

View file

@ -225,9 +225,12 @@ public abstract class AbstractBlockChain {
} }
// Quick check for duplicates to avoid an expensive check further down (in findSplit). This can happen a lot // Quick check for duplicates to avoid an expensive check further down (in findSplit). This can happen a lot
// when connecting orphan transactions due to the dumb brute force algorithm we use. // when connecting orphan transactions due to the dumb brute force algorithm we use.
if (block.equals(getChainHead().getHeader()) || (tryConnecting && orphanBlocks.containsKey(block.getHash()))) { if (block.equals(getChainHead().getHeader())) {
return true; return true;
} }
if (tryConnecting && orphanBlocks.containsKey(block.getHash())) {
return false;
}
// If we want to verify transactions (ie we are running with full blocks), verify that block has transactions // If we want to verify transactions (ie we are running with full blocks), verify that block has transactions
if (shouldVerifyTransactions() && block.transactions == null) if (shouldVerifyTransactions() && block.transactions == null)