Skip to content

Commit

Permalink
Make GetAvailableCredit run GetHash() only once per transaction.
Browse files Browse the repository at this point in the history
This makes the first getbalance/getinfo 63x faster on my wallet.
  • Loading branch information
gmaxwell committed Mar 28, 2014
1 parent 1294cdc commit a60ab0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/wallet.h
Expand Up @@ -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);
Expand Down

0 comments on commit a60ab0b

Please sign in to comment.