mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Transaction hash caching
Use CBlock's vMerkleTree to cache transaction hashes, and pass them along as argument in more function calls. During initial block download, this results in every transaction's hash to be only computed once.
This commit is contained in:
@@ -479,9 +479,8 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
|
||||
// Add a transaction to the wallet, or update it.
|
||||
// pblock is optional, but should be provided if the transaction is known to be in a block.
|
||||
// If fUpdate is true, existing transactions will be updated.
|
||||
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fFindBlock)
|
||||
bool CWallet::AddToWalletIfInvolvingMe(const uint256 &hash, const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fFindBlock)
|
||||
{
|
||||
uint256 hash = tx.GetHash();
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
bool fExisted = mapWallet.count(hash);
|
||||
@@ -756,7 +755,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
block.ReadFromDisk(pindex, true);
|
||||
BOOST_FOREACH(CTransaction& tx, block.vtx)
|
||||
{
|
||||
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
|
||||
if (AddToWalletIfInvolvingMe(tx.GetHash(), tx, &block, fUpdate))
|
||||
ret++;
|
||||
}
|
||||
pindex = pindex->pnext;
|
||||
|
||||
Reference in New Issue
Block a user