aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
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/main.h
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/main.h')
-rw-r--r--src/main.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h
index 0ec68b612b..3ee0108f46 100644
--- a/src/main.h
+++ b/src/main.h
@@ -91,7 +91,7 @@ class CCoinsView;
void RegisterWallet(CWallet* pwalletIn);
void UnregisterWallet(CWallet* pwalletIn);
-void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fUpdate = false);
+void SyncWithWallets(const uint256 &hash, const CTransaction& tx, const CBlock* pblock = NULL, bool fUpdate = false);
bool ProcessBlock(CNode* pfrom, CBlock* pblock);
bool CheckDiskSpace(uint64 nAdditionalBytes=0);
FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly = false);
@@ -577,7 +577,7 @@ public:
bool CheckInputs(CCoinsView &view, enum CheckSig_mode csmode, bool fStrictPayToScriptHash=true, bool fStrictEncodings=true) const;
// Apply the effects of this transaction on the UTXO set represented by view
- bool UpdateCoins(CCoinsView &view, CTxUndo &txundo, int nHeight) const;
+ bool UpdateCoins(CCoinsView &view, CTxUndo &txundo, int nHeight, const uint256 &txhash) const;
// Context-independent validity checks
bool CheckTransaction() const;
@@ -1111,6 +1111,12 @@ public:
return (vMerkleTree.empty() ? 0 : vMerkleTree.back());
}
+ const uint256 &GetTxHash(unsigned int nIndex) const {
+ assert(vMerkleTree.size() > 0); // BuildMerkleTree must have been called first
+ assert(nIndex < vtx.size());
+ return vMerkleTree[nIndex];
+ }
+
std::vector<uint256> GetMerkleBranch(int nIndex) const
{
if (vMerkleTree.empty())