3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 10:45:51 +00:00

Handle duplicate chain.add calls significantly more effeciently.

This commit is contained in:
Matt Corallo 2013-05-18 03:22:13 +02:00
parent ecca1c6f47
commit 68e6228356

View File

@ -320,6 +320,12 @@ public abstract class AbstractBlockChain {
if (shouldVerifyTransactions() && block.transactions == null) if (shouldVerifyTransactions() && block.transactions == null)
throw new VerificationException("Got a block header while running in full-block mode"); throw new VerificationException("Got a block header while running in full-block mode");
// Check for already-seen block, but only for full pruned mode, where the DB is
// more likely able to handle these queries quickly.
if (shouldVerifyTransactions() && blockStore.get(block.getHash()) != null) {
return true;
}
// Does this block contain any transactions we might care about? Check this up front before verifying the // Does this block contain any transactions we might care about? Check this up front before verifying the
// blocks validity so we can skip the merkle root verification if the contents aren't interesting. This saves // blocks validity so we can skip the merkle root verification if the contents aren't interesting. This saves
// a lot of time for big blocks. // a lot of time for big blocks.