From 8da9dd0725ea90b1fd085d9551177fe62d7a9ba2 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 10 Jun 2013 09:38:13 -0400 Subject: [PATCH] Wallet: optimize rescan to skip blocks prior to birthday --- src/wallet.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wallet.cpp b/src/wallet.cpp index aa1371111..9a4a92cd5 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -790,6 +790,13 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) LOCK(cs_wallet); while (pindex) { + // no need to read and scan block, if block was created before + // our wallet birthday (as adjusted for block time variability) + if (nTimeFirstKey && (pindex->nTime < (nTimeFirstKey - 7200))) { + pindex = pindex->GetNextInMainChain(); + continue; + } + CBlock block; block.ReadFromDisk(pindex); BOOST_FOREACH(CTransaction& tx, block.vtx)