Switch CScriptCheck to use Coin instead of CCoins
This commit is contained in:
parent
c87b957a32
commit
8b3868c1b4
2 changed files with 12 additions and 11 deletions
|
@ -470,18 +470,19 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
|
||||||
for (int i=0; i<20; i++)
|
for (int i=0; i<20; i++)
|
||||||
threadGroup.create_thread(boost::bind(&CCheckQueue<CScriptCheck>::Thread, boost::ref(scriptcheckqueue)));
|
threadGroup.create_thread(boost::bind(&CCheckQueue<CScriptCheck>::Thread, boost::ref(scriptcheckqueue)));
|
||||||
|
|
||||||
CCoins coins;
|
std::vector<Coin> coins;
|
||||||
coins.fCoinBase = false;
|
|
||||||
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
||||||
CTxOut txout;
|
Coin coin;
|
||||||
txout.nValue = 1000;
|
coin.nHeight = 1;
|
||||||
txout.scriptPubKey = scriptPubKey;
|
coin.fCoinBase = false;
|
||||||
coins.vout.push_back(txout);
|
coin.out.nValue = 1000;
|
||||||
|
coin.out.scriptPubKey = scriptPubKey;
|
||||||
|
coins.emplace_back(std::move(coin));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
||||||
std::vector<CScriptCheck> vChecks;
|
std::vector<CScriptCheck> vChecks;
|
||||||
const CTxOut& output = coins.vout[tx.vin[i].prevout.n];
|
const CTxOut& output = coins[tx.vin[i].prevout.n].out;
|
||||||
CScriptCheck check(output.scriptPubKey, output.nValue, tx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false, &txdata);
|
CScriptCheck check(output.scriptPubKey, output.nValue, tx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false, &txdata);
|
||||||
vChecks.push_back(CScriptCheck());
|
vChecks.push_back(CScriptCheck());
|
||||||
check.swap(vChecks.back());
|
check.swap(vChecks.back());
|
||||||
|
|
|
@ -1116,16 +1116,16 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
|
||||||
if (fScriptChecks) {
|
if (fScriptChecks) {
|
||||||
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
||||||
const COutPoint &prevout = tx.vin[i].prevout;
|
const COutPoint &prevout = tx.vin[i].prevout;
|
||||||
const CCoins* coins = inputs.AccessCoins(prevout.hash);
|
const Coin& coin = inputs.AccessCoin(prevout);
|
||||||
assert(coins);
|
assert(!coin.IsPruned());
|
||||||
|
|
||||||
// We very carefully only pass in things to CScriptCheck which
|
// We very carefully only pass in things to CScriptCheck which
|
||||||
// are clearly committed to by tx' witness hash. This provides
|
// are clearly committed to by tx' witness hash. This provides
|
||||||
// a sanity check that our caching is not introducing consensus
|
// a sanity check that our caching is not introducing consensus
|
||||||
// failures through additional data in, eg, the coins being
|
// failures through additional data in, eg, the coins being
|
||||||
// spent being checked as a part of CScriptCheck.
|
// spent being checked as a part of CScriptCheck.
|
||||||
const CScript& scriptPubKey = coins->vout[prevout.n].scriptPubKey;
|
const CScript& scriptPubKey = coin.out.scriptPubKey;
|
||||||
const CAmount amount = coins->vout[prevout.n].nValue;
|
const CAmount amount = coin.out.nValue;
|
||||||
|
|
||||||
// Verify signature
|
// Verify signature
|
||||||
CScriptCheck check(scriptPubKey, amount, tx, i, flags, cacheStore, &txdata);
|
CScriptCheck check(scriptPubKey, amount, tx, i, flags, cacheStore, &txdata);
|
||||||
|
|
Loading…
Reference in a new issue