aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2014-09-02 21:21:15 +0200
committerPieter Wuille <[email protected]>2014-09-03 14:24:52 +0200
commit629d75faac84bc0a00533d01dd291a4e6394a51f (patch)
treeb855afa03cefc473be513288880dbc1da34d8d1a /src/miner.cpp
parentMerge pull request #4812 (diff)
downloaddiscoin-629d75faac84bc0a00533d01dd291a4e6394a51f.tar.xz
discoin-629d75faac84bc0a00533d01dd291a4e6394a51f.zip
Combine CCoinsViewCache's HaveCoins and const GetCoins into AccessCoins.
The efficient version of CCoinsViewCache::GetCoins only works for known-to-exist cache entries, requiring a separate HaveCoins call beforehand. This is inefficient as both perform a hashtable lookup. Replace the non-mutable GetCoins with AccessCoins, which returns a potentially-NULL pointer. This also decreases the overloading of GetCoins. Also replace some copying (inefficient) GetCoins calls with equivalent AccessCoins, decreasing the copying.
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 96dc80a26..d05ddbeb1 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -167,12 +167,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nTotalIn += mempool.mapTx[txin.prevout.hash].GetTx().vout[txin.prevout.n].nValue;
continue;
}
- const CCoins &coins = view.GetCoins(txin.prevout.hash);
+ const CCoins* coins = view.AccessCoins(txin.prevout.hash);
+ assert(coins);
- int64_t nValueIn = coins.vout[txin.prevout.n].nValue;
+ int64_t nValueIn = coins->vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
- int nConf = pindexPrev->nHeight - coins.nHeight + 1;
+ int nConf = pindexPrev->nHeight - coins->nHeight + 1;
dPriority += (double)nValueIn * nConf;
}