aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-07-08 00:06:34 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-10-20 23:08:57 +0200
commit64dd46fd05de1dd8ff5066e192e1345f733c6a1f (patch)
tree40b287fafe4b309c0dd6e20cc44746e04d267f3c /src/wallet.cpp
parentae8bfd12daa802d20791e69d3477e799d2b99f45 (diff)
downloadbitcoin-64dd46fd05de1dd8ff5066e192e1345f733c6a1f.tar.xz
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.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 5b32034696..1498ff28b7 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -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;