From a60ab0ba89289433563c4c0993904acbca8c99ff Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Fri, 28 Mar 2014 09:58:40 -0700 Subject: [PATCH] Make GetAvailableCredit run GetHash() only once per transaction. This makes the first getbalance/getinfo 63x faster on my wallet. --- src/wallet.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet.h b/src/wallet.h index e2e89fffe7e86..487c258a20e24 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -620,9 +620,10 @@ class CWalletTx : public CMerkleTx return nAvailableCreditCached; int64_t nCredit = 0; + uint256 hashTx = GetHash(); for (unsigned int i = 0; i < vout.size(); i++) { - if (!pwallet->IsSpent(GetHash(), i)) + if (!pwallet->IsSpent(hashTx, i)) { const CTxOut &txout = vout[i]; nCredit += pwallet->GetCredit(txout);