mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-13 17:15:11 +01:00
refactor: Rely on returned value of GetCoin instead of parameter
Also removed the unused coin parameter of GetCoin. Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
This commit is contained in:
@@ -180,18 +180,14 @@ std::optional<std::vector<int>> CalculatePrevHeights(
|
||||
std::vector<int> prev_heights;
|
||||
prev_heights.resize(tx.vin.size());
|
||||
for (size_t i = 0; i < tx.vin.size(); ++i) {
|
||||
const CTxIn& txin = tx.vin[i];
|
||||
Coin coin;
|
||||
if (!coins.GetCoin(txin.prevout, coin)) {
|
||||
if (auto coin{coins.GetCoin(tx.vin[i].prevout)}) {
|
||||
prev_heights[i] = coin->nHeight == MEMPOOL_HEIGHT
|
||||
? tip.nHeight + 1 // Assume all mempool transaction confirm in the next block.
|
||||
: coin->nHeight;
|
||||
} else {
|
||||
LogPrintf("ERROR: %s: Missing input %d in transaction \'%s\'\n", __func__, i, tx.GetHash().GetHex());
|
||||
return std::nullopt;
|
||||
}
|
||||
if (coin.nHeight == MEMPOOL_HEIGHT) {
|
||||
// Assume all mempool transaction confirm in the next block.
|
||||
prev_heights[i] = tip.nHeight + 1;
|
||||
} else {
|
||||
prev_heights[i] = coin.nHeight;
|
||||
}
|
||||
}
|
||||
return prev_heights;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user