diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-11-05 02:47:07 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2013-11-10 19:37:56 +0100 |
commit | a0fa20a12b69717636050dd8742713b1d82ae524 (patch) | |
tree | d1db4dc173a9f4d24904a1636f5cf82cd3c1c737 /src/txmempool.cpp | |
parent | 84674082b0c4cfcdd54fb97a29bc841aa7f691c2 (diff) |
Move CCoins-related logic to coins.{cpp.h}
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 975955a458..d501b89ecf 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -105,7 +105,7 @@ void CTxMemPool::clear() ++nTransactionsUpdated; } -void CTxMemPool::check(CTxMemPool::CoinLookupFunc fnLookup) const +void CTxMemPool::check(CCoinsViewCache *pcoins) const { if (!fSanityCheck) return; @@ -121,7 +121,7 @@ void CTxMemPool::check(CTxMemPool::CoinLookupFunc fnLookup) const if (it2 != mapTx.end()) { assert(it2->second.vout.size() > txin.prevout.n && !it2->second.vout[txin.prevout.n].IsNull()); } else { - CCoins &coins = (*fnLookup)(txin.prevout.hash); + CCoins &coins = pcoins->GetCoins(txin.prevout.hash); assert(coins.IsAvailable(txin.prevout.n)); } // Check whether its inputs are marked in mapNextTx. @@ -160,3 +160,21 @@ bool CTxMemPool::lookup(uint256 hash, CTransaction& result) const result = i->second; return true; } + +CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { } + +bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) { + if (base->GetCoins(txid, coins)) + return true; + CTransaction tx; + if (mempool.lookup(txid, tx)) { + coins = CCoins(tx, MEMPOOL_HEIGHT); + return true; + } + return false; +} + +bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) { + return mempool.exists(txid) || base->HaveCoins(txid); +} + |