Skip to content

Commit

Permalink
working build
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Nov 15, 2018
1 parent 992d54b commit d345979
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ BITCOIN_CORE_H = \
dbwrapper.h \
limitedmap.h \
logging.h \
mainchainrpc.h \
memusage.h \
merkleblock.h \
miner.h \
Expand Down Expand Up @@ -229,6 +230,7 @@ libbitcoin_server_a_SOURCES = \
index/txindex.cpp \
init.cpp \
dbwrapper.cpp \
mainchainrpc.cpp \
merkleblock.cpp \
miner.cpp \
net.cpp \
Expand Down
4 changes: 3 additions & 1 deletion src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
bool spendsCoinbase = false;
unsigned int sigOpCost = 4;
LockPoints lp;
std::set<std::pair<uint256, COutPoint>> setPeginsSpent;
pool.addUnchecked(tx->GetHash(), CTxMemPoolEntry(
tx, nFee, nTime, nHeight,
spendsCoinbase, sigOpCost, lp));
spendsCoinbase, sigOpCost, lp,
setPeginsSpent));
}

// Right now this is only testing eviction performance in an extremely small
Expand Down
14 changes: 7 additions & 7 deletions src/mainchainrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)

UniValue CallMainChainRPC(const std::string& strMethod, const UniValue& params)
{
std::string host = GetArg("-mainchainrpchost", DEFAULT_RPCCONNECT);
int port = GetArg("-mainchainrpcport", BaseParams().MainchainRPCPort());
std::string host = gArgs.GetArg("-mainchainrpchost", DEFAULT_RPCCONNECT);
int port = gArgs.GetArg("-mainchainrpcport", BaseParams().MainchainRPCPort());

// Obtain event base
raii_event_base base = obtain_event_base();

// Synchronously look up hostname
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
evhttp_connection_set_timeout(evcon.get(), GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));

HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
Expand All @@ -99,13 +99,13 @@ UniValue CallMainChainRPC(const std::string& strMethod, const UniValue& params)

// Get credentials
std::string strRPCUserColonPass;
if (GetArg("-mainchainrpcpassword", "") == "" && !GetMainchainAuthCookie(&strRPCUserColonPass)) {
if (gArgs.GetArg("-mainchainrpcpassword", "") == "" && !GetMainchainAuthCookie(&strRPCUserColonPass)) {
// Try fall back to cookie-based authentication if no password is provided
throw std::runtime_error(strprintf(
_("Could not locate mainchain RPC credentials. No authentication cookie could be found, and no mainchainrpcpassword is set in the configuration file (%s)"),
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
} else {
strRPCUserColonPass = GetArg("-mainchainrpcuser", "") + ":" + GetArg("-mainchainrpcpassword", "");
strRPCUserColonPass = gArgs.GetArg("-mainchainrpcuser", "") + ":" + gArgs.GetArg("-mainchainrpcpassword", "");
}

struct evkeyvalq* output_headers = evhttp_request_get_output_headers(req.get());
Expand Down Expand Up @@ -153,7 +153,7 @@ bool IsConfirmedBitcoinBlock(const uint256& hash, const int nMinConfirmationDept
try {
UniValue params(UniValue::VARR);
params.push_back(hash.GetHex());
UniValue reply = CallMainChainRPC("getblockheader", params, true);
UniValue reply = CallMainChainRPC("getblockheader", params);
if (!find_value(reply, "error").isNull())
return false;
UniValue result = find_value(reply, "result");
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
}
}

static UniValue sendrawtransaction(const JSONRPCRequest& request)
UniValue sendrawtransaction(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw std::runtime_error(
Expand Down
95 changes: 93 additions & 2 deletions src/test/mempool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <policy/policy.h>
#include <policy/fees.h>
#include <txmempool.h>
#include <util.h>

Expand Down Expand Up @@ -389,7 +390,8 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
/* after tx6 is mined, tx7 should move up in the sort */
std::vector<CTransactionRef> vtx;
vtx.push_back(MakeTransactionRef(tx6));
pool.removeForBlock(vtx, 1);
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
pool.removeForBlock(vtx, 1, setPeginsSpentDummy);

sortedOrder.erase(sortedOrder.begin()+1);
// Ties are broken by hash
Expand Down Expand Up @@ -418,6 +420,94 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
CheckSort<ancestor_score>(pool, sortedOrder);
}

// ELEMENTS:
BOOST_AUTO_TEST_CASE(WithdrawsSpentTest)
{
CBlockPolicyEstimator feeEst;
CTxMemPool pool(&feeEst);
//TODO(stevenroose) remove
//CTxMemPool pool(CFeeRate(0));

std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
TestMemPoolEntryHelper entry;

std::pair<uint256, COutPoint> withdraw1, withdraw2, withdraw3;
GetRandBytes(withdraw1.first.begin(), withdraw1.first.size());
GetRandBytes(withdraw2.first.begin(), withdraw2.first.size());
GetRandBytes(withdraw3.first.begin(), withdraw3.first.size());
GetRandBytes(withdraw1.second.hash.begin(), withdraw1.second.hash.size());
GetRandBytes(withdraw2.second.hash.begin(), withdraw2.second.hash.size());
withdraw3.second.hash = withdraw2.second.hash;
withdraw1.second.n = 0;
withdraw2.second.n = 0;
withdraw3.second.n = 1;

CMutableTransaction tx;
tx.vin.resize(1);
tx.vout.resize(1);
tx.vout[0].nValue = 0;
const uint256 tx1Hash(tx.GetHash());
pool.addUnchecked(tx1Hash, entry.WithdrawsSpent(setPeginsSpent).FromTx(tx));
BOOST_CHECK(pool.mapWithdrawsSpentToTxid.empty());

setPeginsSpent = {withdraw1};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(2);
tx.vout[1].nValue = 0;
const uint256 tx2Hash(tx.GetHash());
pool.addUnchecked(tx2Hash, entry.WithdrawsSpent(setPeginsSpent).FromTx(tx));
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw1].ToString(), tx2Hash.ToString());

setPeginsSpent = {withdraw2};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(3);
tx.vout[2].nValue = 0;
const uint256 tx3Hash(tx.GetHash());
pool.addUnchecked(tx3Hash, entry.WithdrawsSpent(setPeginsSpent).FromTx(tx));
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw2].ToString(), tx3Hash.ToString());

setPeginsSpent = {withdraw3};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(4);
tx.vout[3].nValue = 0;
CTransactionRef txref(MakeTransactionRef(tx));
pool.removeForBlock({txref}, 1, setPeginsSpent);

BOOST_CHECK_EQUAL(pool.size(), 3);
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid.size(), 2);
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw1].ToString(), tx2Hash.ToString());
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw2].ToString(), tx3Hash.ToString());

setPeginsSpent = {withdraw1};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(5);
tx.vout[4].nValue = 0;
txref = MakeTransactionRef(tx);
pool.removeForBlock({txref}, 2, setPeginsSpent);

BOOST_CHECK_EQUAL(pool.size(), 2);
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid.size(), 1);
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw2].ToString(), tx3Hash.ToString());

setPeginsSpent = {withdraw1, withdraw3};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(6);
tx.vout[5].nValue = 0;
const uint256 tx4Hash(tx.GetHash());
pool.addUnchecked(tx4Hash, entry.WithdrawsSpent(setPeginsSpent).FromTx(tx));
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw1].ToString(), tx4Hash.ToString());
BOOST_CHECK_EQUAL(pool.mapWithdrawsSpentToTxid[withdraw3].ToString(), tx4Hash.ToString());

setPeginsSpent = {withdraw2, withdraw3};
GetRandBytes(tx.vin[0].prevout.hash.begin(), tx.vin[0].prevout.hash.size());
tx.vout.resize(7);
tx.vout[6].nValue = 0;
txref = MakeTransactionRef(tx);
pool.removeForBlock({txref}, 3, setPeginsSpent);

BOOST_CHECK_EQUAL(pool.size(), 1);
BOOST_CHECK(pool.mapWithdrawsSpentToTxid.empty());
}

BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
{
Expand Down Expand Up @@ -549,7 +639,8 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1000);
// ... we should keep the same min fee until we get a block
pool.removeForBlock(vtx, 1);
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
pool.removeForBlock(vtx, 1, setPeginsSpentDummy);
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE);
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + 1000)/2.0));
// ... then feerate should drop 1/2 each halflife
Expand Down
11 changes: 6 additions & 5 deletions src/test/policyestimator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
CAmount basefee(2000);
CAmount deltaFee(100);
std::vector<CAmount> feeV;
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;

// Populate vectors of increasing fees
for (int j = 0; j < 10; j++) {
Expand Down Expand Up @@ -74,7 +75,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
txHashes[9-h].pop_back();
}
}
mpool.removeForBlock(block, ++blocknum);
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
block.clear();
// Check after just a few txs that combining buckets works as expected
if (blocknum == 3) {
Expand Down Expand Up @@ -113,7 +114,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
// We haven't decayed the moving average enough so we still have enough data points in every bucket
while (blocknum < 250)
mpool.removeForBlock(block, ++blocknum);
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);

BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));
for (int i = 2; i < 10;i++) {
Expand All @@ -133,7 +134,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
txHashes[j].push_back(hash);
}
}
mpool.removeForBlock(block, ++blocknum);
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
}

for (int i = 1; i < 10;i++) {
Expand All @@ -150,7 +151,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
txHashes[j].pop_back();
}
}
mpool.removeForBlock(block, 266);
mpool.removeForBlock(block, 266, setPeginsSpentDummy);
block.clear();
BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));
for (int i = 2; i < 10;i++) {
Expand All @@ -171,7 +172,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)

}
}
mpool.removeForBlock(block, ++blocknum);
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
block.clear();
}
BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction &tx) {
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx)
{
return CTxMemPoolEntry(tx, nFee, nTime, nHeight,
spendsCoinbase, sigOpCost, lp);
spendsCoinbase, sigOpCost, lp, setPeginsSpent);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/test/test_bitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct TestMemPoolEntryHelper
TestMemPoolEntryHelper &Height(unsigned int _height) { nHeight = _height; return *this; }
TestMemPoolEntryHelper &SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
// ELEMENTS:
TestMemPoolEntryHelper &WithdrawsSpent(std::set<std::pair<uint256, COutPoint> >& _setPeginsSpent) { setPeginsSpent = _setPeginsSpent; return *this; }
};

CBlock getBlock13b8a();
Expand Down
25 changes: 15 additions & 10 deletions src/test/txvalidationcache_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <boost/test/unit_test.hpp>

bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks);
bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::set<std::pair<uint256, COutPoint>>& setPeginsSpent, std::vector<CScriptCheck> *pvChecks);

BOOST_AUTO_TEST_SUITE(tx_validationcache_tests)

Expand Down Expand Up @@ -104,6 +104,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
// any script flag that is implemented as an upgraded NOP code.
static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t failing_flags, bool add_to_cache)
{
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
PrecomputedTransactionData txdata(tx);
// If we add many more flags, this loop can get too expensive, but we can
// rewrite in the future to randomly pick a set of flags to evaluate.
Expand All @@ -119,7 +120,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
// WITNESS requires P2SH
test_flags |= SCRIPT_VERIFY_P2SH;
}
bool ret = CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, nullptr);
bool ret = CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, setPeginsSpentDummy, nullptr);
// CheckInputs should succeed iff test_flags doesn't intersect with
// failing_flags
bool expected_return_value = !(test_flags & failing_flags);
Expand All @@ -129,13 +130,13 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
if (ret && add_to_cache) {
// Check that we get a cache hit if the tx was valid
std::vector<CScriptCheck> scriptchecks;
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, &scriptchecks));
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, setPeginsSpentDummy, &scriptchecks));
BOOST_CHECK(scriptchecks.empty());
} else {
// Check that we get script executions to check, if the transaction
// was invalid, or we didn't add to cache.
std::vector<CScriptCheck> scriptchecks;
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, &scriptchecks));
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, test_flags, true, add_to_cache, txdata, setPeginsSpentDummy, &scriptchecks));
BOOST_CHECK_EQUAL(scriptchecks.size(), tx.vin.size());
}
}
Expand Down Expand Up @@ -197,14 +198,15 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)

CValidationState state;
PrecomputedTransactionData ptd_spend_tx(spend_tx);
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;

BOOST_CHECK(!CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, nullptr));
BOOST_CHECK(!CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, setPeginsSpentDummy, nullptr));

// If we call again asking for scriptchecks (as happens in
// ConnectBlock), we should add a script check object for this -- we're
// not caching invalidity (if that changes, delete this test case).
std::vector<CScriptCheck> scriptchecks;
BOOST_CHECK(CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, &scriptchecks));
BOOST_CHECK(CheckInputs(spend_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, setPeginsSpentDummy, &scriptchecks));
BOOST_CHECK_EQUAL(scriptchecks.size(), 1U);

// Test that CheckInputs returns true iff DERSIG-enforcing flags are
Expand Down Expand Up @@ -267,7 +269,8 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
invalid_with_cltv_tx.vin[0].scriptSig = CScript() << vchSig << 100;
CValidationState state;
PrecomputedTransactionData txdata(invalid_with_cltv_tx);
BOOST_CHECK(CheckInputs(invalid_with_cltv_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true, true, txdata, nullptr));
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
BOOST_CHECK(CheckInputs(invalid_with_cltv_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true, true, txdata, setPeginsSpentDummy, nullptr));
}

// TEST CHECKSEQUENCEVERIFY
Expand Down Expand Up @@ -295,7 +298,8 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
invalid_with_csv_tx.vin[0].scriptSig = CScript() << vchSig << 100;
CValidationState state;
PrecomputedTransactionData txdata(invalid_with_csv_tx);
BOOST_CHECK(CheckInputs(invalid_with_csv_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true, true, txdata, nullptr));
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
BOOST_CHECK(CheckInputs(invalid_with_csv_tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true, true, txdata, setPeginsSpentDummy, nullptr));
}

// TODO: add tests for remaining script flags
Expand Down Expand Up @@ -356,13 +360,14 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)

CValidationState state;
PrecomputedTransactionData txdata(tx);
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
// This transaction is now invalid under segwit, because of the second input.
BOOST_CHECK(!CheckInputs(tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, nullptr));
BOOST_CHECK(!CheckInputs(tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, setPeginsSpentDummy, nullptr));

std::vector<CScriptCheck> scriptchecks;
// Make sure this transaction was not cached (ie because the first
// input was valid)
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, &scriptchecks));
BOOST_CHECK(CheckInputs(tx, state, pcoinsTip.get(), true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, setPeginsSpentDummy, &scriptchecks));
// Should get 2 script checks back -- caching is on a whole-transaction basis.
BOOST_CHECK_EQUAL(scriptchecks.size(), 2U);
}
Expand Down
5 changes: 5 additions & 0 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const {
return base->GetCoin(outpoint, coin);
}

// ELEMENTS:
bool CCoinsViewMemPool::IsWithdrawSpent(const std::pair<uint256, COutPoint> &outpoint) const {
return mempool.mapWithdrawsSpentToTxid.count(outpoint) || base->IsWithdrawSpent(outpoint);
}

size_t CTxMemPool::DynamicMemoryUsage() const {
LOCK(cs);
// Estimate the overhead of mapTx to be 12 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl

// ELEMENTS:
// Used when ConnectBlock() results are unneeded for mempool ejection
std::set<std::pair<uint256, COutPoint> > setPeginsSpentDummy;
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;

for (unsigned int i = 0; i < block.vtx.size(); i++)
{
Expand Down
Loading

0 comments on commit d345979

Please sign in to comment.