MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetCoin

Method GetCoin

src/txmempool.cpp:1101–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1099CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
1100
1101bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const {
1102 // Check to see if the inputs are made available by another tx in the package.
1103 // These Coins would not be available in the underlying CoinsView.
1104 if (auto it = m_temp_added.find(outpoint); it != m_temp_added.end()) {
1105 coin = it->second;
1106 return true;
1107 }
1108
1109 // If an entry in the mempool exists, always return that one, as it's guaranteed to never
1110 // conflict with the underlying cache, and it cannot have pruned entries (as it contains full)
1111 // transactions. First checking the underlying cache risks returning a pruned entry instead.
1112 CTransactionRef ptx = mempool.get(outpoint.hash);
1113 if (ptx) {
1114 if (outpoint.n < ptx->vout.size()) {
1115 coin = Coin(ptx->vout[outpoint.n], MEMPOOL_HEIGHT, false);
1116 return true;
1117 } else {
1118 return false;
1119 }
1120 }
1121 return base->GetCoin(outpoint, coin);
1122}
1123
1124void CCoinsViewMemPool::PackageAddTransaction(const CTransactionRef& tx)
1125{

Callers

nothing calls this directly

Calls 5

findMethod · 0.80
CoinClass · 0.70
endMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected