Make GetAvailableCredit run GetHash() only once per transaction.

This makes the first getbalance/getinfo 63x faster on my wallet.

(cherry picked from commit bitcoin/bitcoin@a60ab0ba89)
This commit is contained in:
Gregory Maxwell 2014-03-28 09:58:40 -07:00 committed by Jannis Froese
parent 112c5c95a7
commit 0fbd54e5cc

View file

@ -620,9 +620,10 @@ public:
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);