Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | if (lp->maxInputBlock) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// LockPoints still valid | // LockPoints still valid | ||||
return true; | return true; | ||||
} | } | ||||
bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints *lp, | bool CheckSequenceLocks(const CTxMemPool &pool, const CTransaction &tx, | ||||
bool useExistingLockPoints) { | int flags, LockPoints *lp, bool useExistingLockPoints) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
AssertLockHeld(g_mempool.cs); | AssertLockHeld(pool.cs); | ||||
CBlockIndex *tip = chainActive.Tip(); | CBlockIndex *tip = chainActive.Tip(); | ||||
assert(tip != nullptr); | assert(tip != nullptr); | ||||
CBlockIndex index; | CBlockIndex index; | ||||
index.pprev = tip; | index.pprev = tip; | ||||
// CheckSequenceLocks() uses chainActive.Height()+1 to evaluate height based | // CheckSequenceLocks() uses chainActive.Height()+1 to evaluate height based | ||||
// locks because when SequenceLocks() is called within ConnectBlock(), the | // locks because when SequenceLocks() is called within ConnectBlock(), the | ||||
// height of the block *being* evaluated is what is used. Thus if we want to | // height of the block *being* evaluated is what is used. Thus if we want to | ||||
// know if a transaction can be part of the *next* block, we need to use one | // know if a transaction can be part of the *next* block, we need to use one | ||||
// more than chainActive.Height() | // more than chainActive.Height() | ||||
index.nHeight = tip->nHeight + 1; | index.nHeight = tip->nHeight + 1; | ||||
std::pair<int, int64_t> lockPair; | std::pair<int, int64_t> lockPair; | ||||
if (useExistingLockPoints) { | if (useExistingLockPoints) { | ||||
assert(lp); | assert(lp); | ||||
lockPair.first = lp->height; | lockPair.first = lp->height; | ||||
lockPair.second = lp->time; | lockPair.second = lp->time; | ||||
} else { | } else { | ||||
// pcoinsTip contains the UTXO set for chainActive.Tip() | // pcoinsTip contains the UTXO set for chainActive.Tip() | ||||
CCoinsViewMemPool viewMemPool(pcoinsTip.get(), g_mempool); | CCoinsViewMemPool viewMemPool(pcoinsTip.get(), pool); | ||||
std::vector<int> prevheights; | std::vector<int> prevheights; | ||||
prevheights.resize(tx.vin.size()); | prevheights.resize(tx.vin.size()); | ||||
for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { | for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { | ||||
const CTxIn &txin = tx.vin[txinIndex]; | const CTxIn &txin = tx.vin[txinIndex]; | ||||
Coin coin; | Coin coin; | ||||
if (!viewMemPool.GetCoin(txin.prevout, coin)) { | if (!viewMemPool.GetCoin(txin.prevout, coin)) { | ||||
return error("%s: Missing input", __func__); | return error("%s: Missing input", __func__); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
// need to keep lock on mempool. | // need to keep lock on mempool. | ||||
view.SetBackend(dummy); | view.SetBackend(dummy); | ||||
// Only accept BIP68 sequence locked transactions that can be mined in | // Only accept BIP68 sequence locked transactions that can be mined in | ||||
// the next block; we don't want our mempool filled up with transactions | // the next block; we don't want our mempool filled up with transactions | ||||
// that can't be mined yet. Must keep pool.cs for this unless we change | // that can't be mined yet. Must keep pool.cs for this unless we change | ||||
// CheckSequenceLocks to take a CoinsViewCache instead of create its | // CheckSequenceLocks to take a CoinsViewCache instead of create its | ||||
// own. | // own. | ||||
if (!CheckSequenceLocks(tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp)) { | if (!CheckSequenceLocks(pool, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, | ||||
&lp)) { | |||||
return state.DoS(0, false, REJECT_NONSTANDARD, "non-BIP68-final"); | return state.DoS(0, false, REJECT_NONSTANDARD, "non-BIP68-final"); | ||||
} | } | ||||
Amount nFees = Amount::zero(); | Amount nFees = Amount::zero(); | ||||
if (!Consensus::CheckTxInputs(tx, state, view, GetSpendHeight(view), | if (!Consensus::CheckTxInputs(tx, state, view, GetSpendHeight(view), | ||||
nFees)) { | nFees)) { | ||||
return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, | return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, | ||||
tx.GetId().ToString(), FormatStateMessage(state)); | tx.GetId().ToString(), FormatStateMessage(state)); | ||||
▲ Show 20 Lines • Show All 5,115 Lines • Show Last 20 Lines |