Clarify claimtrie allocation
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
4b03309a64
commit
5005e95d05
25 changed files with 270 additions and 238 deletions
|
@ -25,17 +25,6 @@ static void AssembleBlock(benchmark::State& state)
|
|||
|
||||
const CScript SCRIPT_PUB{CScript(OP_0) << std::vector<unsigned char>{witness_program.begin(), witness_program.end()}};
|
||||
|
||||
delete ::pclaimTrie;
|
||||
const CChainParams& chainparams = Params();
|
||||
auto &consensus = chainparams.GetConsensus();
|
||||
::pclaimTrie = new CClaimTrie(1 << 25, true, 0, GetDataDir().string(),
|
||||
consensus.nNormalizedNameForkHeight,
|
||||
consensus.nMinRemovalWorkaroundHeight,
|
||||
consensus.nMaxRemovalWorkaroundHeight,
|
||||
consensus.nOriginalClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationForkHeight,
|
||||
consensus.nAllClaimsInMerkleForkHeight, 1);
|
||||
// Collect some loose transactions that spend the coinbases of our mined blocks
|
||||
constexpr size_t NUM_BLOCKS{200};
|
||||
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
|
||||
|
|
|
@ -8,6 +8,7 @@ class CClaimTrieCacheExpirationFork : public CClaimTrieCacheBase
|
|||
{
|
||||
public:
|
||||
explicit CClaimTrieCacheExpirationFork(CClaimTrie* base);
|
||||
CClaimTrieCacheExpirationFork(CClaimTrieCacheExpirationFork&&) = default;
|
||||
|
||||
int expirationTime() const override;
|
||||
|
||||
|
@ -27,6 +28,7 @@ class CClaimTrieCacheNormalizationFork : public CClaimTrieCacheExpirationFork
|
|||
{
|
||||
public:
|
||||
explicit CClaimTrieCacheNormalizationFork(CClaimTrie* base);
|
||||
CClaimTrieCacheNormalizationFork(CClaimTrieCacheNormalizationFork&&) = default;
|
||||
|
||||
bool shouldNormalize() const;
|
||||
|
||||
|
@ -55,6 +57,7 @@ class CClaimTrieCacheHashFork : public CClaimTrieCacheNormalizationFork
|
|||
{
|
||||
public:
|
||||
explicit CClaimTrieCacheHashFork(CClaimTrie* base);
|
||||
CClaimTrieCacheHashFork(CClaimTrieCacheHashFork&&) = default;
|
||||
|
||||
bool getProofForName(const std::string& name, const uint160& claim, CClaimTrieProof& proof) override;
|
||||
void initializeIncrement() override;
|
||||
|
|
|
@ -127,6 +127,11 @@ CClaimTrieCacheBase::~CClaimTrieCacheBase()
|
|||
claimHashQueryLimit.used(true);
|
||||
}
|
||||
|
||||
std::size_t CClaimTrie::cache()
|
||||
{
|
||||
return dbCacheBytes;
|
||||
}
|
||||
|
||||
bool CClaimTrie::SyncToDisk()
|
||||
{
|
||||
// alternatively, switch to full sync after we are caught up on the chain
|
||||
|
@ -521,6 +526,18 @@ CClaimTrieCacheBase::CClaimTrieCacheBase(CClaimTrie* base)
|
|||
applyPragmas(db, base->dbCacheBytes >> 10U); // in KB
|
||||
}
|
||||
|
||||
CClaimTrieCacheBase::CClaimTrieCacheBase(CClaimTrieCacheBase&& o)
|
||||
: nNextHeight(o.nNextHeight),
|
||||
base(o.base), db(std::move(o.db)),
|
||||
removalWorkaround(std::move(o.removalWorkaround)),
|
||||
childHashQuery(std::move(o.childHashQuery)),
|
||||
claimHashQuery(std::move(o.claimHashQuery)),
|
||||
claimHashQueryLimit(std::move(o.claimHashQueryLimit)),
|
||||
transacting(o.transacting)
|
||||
{
|
||||
o.transacting = false;
|
||||
}
|
||||
|
||||
void CClaimTrieCacheBase::ensureTransacting()
|
||||
{
|
||||
if (!transacting) {
|
||||
|
|
|
@ -43,10 +43,11 @@ public:
|
|||
|
||||
bool empty();
|
||||
bool SyncToDisk();
|
||||
std::size_t cache();
|
||||
|
||||
protected:
|
||||
int nNextHeight;
|
||||
std::size_t dbCacheBytes;
|
||||
const std::size_t dbCacheBytes;
|
||||
const std::string dbFile;
|
||||
sqlite::database db;
|
||||
const int nProportionalDelayFactor;
|
||||
|
@ -63,7 +64,9 @@ protected:
|
|||
class CClaimTrieCacheBase
|
||||
{
|
||||
public:
|
||||
CClaimTrieCacheBase(CClaimTrieCacheBase&& o);
|
||||
explicit CClaimTrieCacheBase(CClaimTrie* base);
|
||||
|
||||
virtual ~CClaimTrieCacheBase();
|
||||
|
||||
bool flush();
|
||||
|
|
|
@ -22,7 +22,7 @@ static bool IsToKeyID(const CScript& script, CKeyID &hash)
|
|||
if (script.size() == 25 && script[0] == OP_DUP && script[1] == OP_HASH160
|
||||
&& script[2] == 20 && script[23] == OP_EQUALVERIFY
|
||||
&& script[24] == OP_CHECKSIG) {
|
||||
memcpy(&hash, &script[3], 20);
|
||||
memcpy(hash.begin(), &script[3], 20);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -32,7 +32,7 @@ static bool IsToScriptID(const CScript& script, CScriptID &hash)
|
|||
{
|
||||
if (script.size() == 23 && script[0] == OP_HASH160 && script[1] == 20
|
||||
&& script[22] == OP_EQUAL) {
|
||||
memcpy(&hash, &script[2], 20);
|
||||
memcpy(hash.begin(), &script[2], 20);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -207,7 +207,8 @@ void BaseIndex::ThreadSync()
|
|||
bool BaseIndex::Commit()
|
||||
{
|
||||
if (!CommitInternal() || sqlite::commit(GetDB()) != SQLITE_OK) {
|
||||
GetDB() << "rollback; begin";
|
||||
GetDB() << "rollback";
|
||||
GetDB() << "begin";
|
||||
return error("%s: Failed to commit latest %s state", __func__, GetName());
|
||||
}
|
||||
GetDB() << "begin";
|
||||
|
|
|
@ -225,7 +225,7 @@ static bool LookupOne(sqlite::database& db, const CBlockIndex* block_index, DBVa
|
|||
// First check if the result is stored under the height index and the value there matches the
|
||||
// block hash. This should be the case if the block is on the active chain.
|
||||
auto query = db << "SELECT filter_hash, header, file, pos FROM block WHERE (height = ? "
|
||||
<< "OR height IS NULL) AND hash = ? LIMIT 1"
|
||||
"OR height IS NULL) AND hash = ? LIMIT 1"
|
||||
<< block_index->nHeight << block_index->GetBlockHash();
|
||||
|
||||
for (auto&& row : query) {
|
||||
|
|
25
src/init.cpp
25
src/init.cpp
|
@ -265,8 +265,6 @@ void Shutdown(InitInterfaces& interfaces)
|
|||
g_chainstate->ResetCoinsViews();
|
||||
}
|
||||
pblocktree.reset();
|
||||
delete pclaimTrie;
|
||||
pclaimTrie = nullptr;
|
||||
}
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
client->stop();
|
||||
|
@ -1256,6 +1254,9 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
}
|
||||
);
|
||||
|
||||
if (LogInstance().Enabled() && LogAcceptCategory(BCLog::CLAIMS))
|
||||
CLogPrint::global().setLogger(&LogInstance());
|
||||
|
||||
InitSignatureCache();
|
||||
InitScriptExecutionCache();
|
||||
|
||||
|
@ -1439,7 +1440,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
|
||||
int64_t nBlockTreeDBCache = std::min(nTotalCache / 4, nMaxBlockDBCache << 20);
|
||||
int64_t nCoinDBCache = std::min(nTotalCache / 8, nMaxCoinsDBCache << 20);
|
||||
int64_t nClaimtrieCache = nTotalCache / 4;
|
||||
int64_t nClaimtrieCache = ::Claimtrie().cache();
|
||||
nTotalCache -= nBlockTreeDBCache;
|
||||
int64_t filter_index_cache = 0;
|
||||
if (!g_enabled_filter_types.empty()) {
|
||||
|
@ -1546,22 +1547,6 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
"", CClientUIInterface::MSG_ERROR);
|
||||
});
|
||||
|
||||
if (LogInstance().Enabled() && LogAcceptCategory(BCLog::CLAIMS))
|
||||
CLogPrint::global().setLogger(&LogInstance());
|
||||
|
||||
delete pclaimTrie;
|
||||
auto& consensus = chainparams.GetConsensus();
|
||||
pclaimTrie = new CClaimTrie(nClaimtrieCache, fReindex || fReindexChainState, 0,
|
||||
GetDataDir().string(),
|
||||
consensus.nNormalizedNameForkHeight,
|
||||
consensus.nMinRemovalWorkaroundHeight,
|
||||
consensus.nMaxRemovalWorkaroundHeight,
|
||||
consensus.nOriginalClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationForkHeight,
|
||||
consensus.nAllClaimsInMerkleForkHeight,
|
||||
32);
|
||||
|
||||
// ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
||||
if (!::ChainstateActive().ReplayBlocks(chainparams)) {
|
||||
strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.").translated;
|
||||
|
@ -1589,7 +1574,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
}
|
||||
|
||||
auto tip = ::ChainActive().Tip();
|
||||
if (tip && !CClaimTrieCache(pclaimTrie).validateDb(tip->nHeight, tip->hashClaimTrie)) {
|
||||
if (tip && !::ClaimtrieCache().validateDb(tip->nHeight, tip->hashClaimTrie)) {
|
||||
strLoadError = _("Error validating the claim trie from disk").translated;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|||
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
||||
|
||||
{
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
blockToCache(pblock, trieCache, nHeight);
|
||||
pblock->hashClaimTrie = trieCache.getMerkleHash();
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ static UniValue getnamesintrie(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETNAMESINTRIE, 0, 1);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
if (!request.params.empty()) {
|
||||
|
@ -272,7 +272,7 @@ static UniValue getvalueforname(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETVALUEFORNAME, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
if (request.params.size() > 1) {
|
||||
|
@ -320,7 +320,7 @@ UniValue getclaimsforname(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMSFORNAME, 1, 1);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
if (request.params.size() > 1) {
|
||||
|
@ -360,7 +360,7 @@ UniValue getclaimbybid(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMBYBID, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
int bid = 0;
|
||||
|
@ -403,7 +403,7 @@ UniValue getclaimbyseq(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMBYSEQ, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
int seq = 0;
|
||||
|
@ -448,7 +448,7 @@ UniValue getclaimbyid(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMBYID, 1, 0);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
std::string claimId;
|
||||
|
@ -485,7 +485,7 @@ UniValue gettotalclaimednames(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETTOTALCLAIMEDNAMES, 0, 0);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie); // TODO: add rollback support here
|
||||
auto trieCache = ::ClaimtrieCache(); // TODO: add rollback support here
|
||||
auto num_names = trieCache.getTotalNamesInTrie();
|
||||
return int(num_names);
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ UniValue gettotalclaims(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETTOTALCLAIMS, 0, 0);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie); // TODO: add rollback support here
|
||||
auto trieCache = ::ClaimtrieCache(); // TODO: add rollback support here
|
||||
auto num_claims = trieCache.getTotalClaimsInTrie();
|
||||
return int(num_claims);
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ UniValue gettotalvalueofclaims(const JSONRPCRequest& request)
|
|||
bool controlling_only = false;
|
||||
if (request.params.size() == 1)
|
||||
controlling_only = request.params[0].get_bool();
|
||||
CClaimTrieCache trieCache(pclaimTrie); // TODO: add rollback support here
|
||||
auto trieCache = ::ClaimtrieCache(); // TODO: add rollback support here
|
||||
auto total_amount = trieCache.getTotalValueOfClaimsInTrie(controlling_only);
|
||||
return ValueFromAmount(total_amount);
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ UniValue getclaimsfortx(const JSONRPCRequest& request)
|
|||
int op;
|
||||
std::vector<std::vector<unsigned char> > vvchParams;
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache view(&::ChainstateActive().CoinsTip());
|
||||
|
||||
const Coin& coin = AccessByTxid(view, hash);
|
||||
|
@ -646,7 +646,7 @@ UniValue getnameproof(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETNAMEPROOF, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
int validHeight = ::ChainActive().Tip()->nHeight;
|
||||
|
@ -683,7 +683,7 @@ UniValue getclaimproofbybid(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMPROOFBYBID, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
int bid = 0;
|
||||
|
@ -717,7 +717,7 @@ UniValue getclaimproofbyseq(const JSONRPCRequest& request)
|
|||
validateRequest(request, GETCLAIMPROOFBYSEQ, 1, 2);
|
||||
|
||||
LOCK(cs_main);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CCoinsViewCache coinsCache(&::ChainstateActive().CoinsTip());
|
||||
|
||||
int seq = 0;
|
||||
|
@ -766,7 +766,7 @@ UniValue getchangesinblock(const JSONRPCRequest& request)
|
|||
if (request.params.size() > 0)
|
||||
index = BlockHashIndex(ParseHashV(request.params[0], T_BLOCKHASH " (optional parameter)"));
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
RollBackTo(index, coinsCache, trieCache);
|
||||
if (!ReadBlockFromDisk(block, index, Params().GetConsensus()))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
||||
|
@ -859,8 +859,8 @@ UniValue checknormalization(const JSONRPCRequest& request)
|
|||
const bool force = true;
|
||||
const std::string name = request.params[0].get_str();
|
||||
|
||||
CClaimTrieCache triecache(pclaimTrie);
|
||||
return triecache.normalizeClaimName(name, force);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
return trieCache.normalizeClaimName(name, force);
|
||||
}
|
||||
|
||||
static const CRPCCommand commands[] =
|
||||
|
|
|
@ -29,7 +29,6 @@ static inline void RegisterAllCoreRPCCommands(CRPCTable &t)
|
|||
RegisterMiscRPCCommands(t);
|
||||
RegisterMiningRPCCommands(t);
|
||||
RegisterRawTransactionRPCCommands(t);
|
||||
RegisterRawTransactionRPCCommands(t);
|
||||
RegisterClaimTrieRPCCommands(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -439,6 +439,11 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
|
|||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
|
||||
}
|
||||
|
||||
void CRPCTable::clear()
|
||||
{
|
||||
mapCommands.clear();
|
||||
}
|
||||
|
||||
CRPCCaller CRPCTable::operator[](const std::string &name) const
|
||||
{
|
||||
auto it = mapCommands.find(name);
|
||||
|
|
|
@ -117,9 +117,9 @@ public:
|
|||
|
||||
class CRPCCaller
|
||||
{
|
||||
const CRPCCommand::Actor& actor;
|
||||
const CRPCCommand::Actor actor;
|
||||
public:
|
||||
explicit CRPCCaller(const CRPCCommand::Actor& actor) : actor(actor) {}
|
||||
explicit CRPCCaller(CRPCCommand::Actor actor) : actor(std::move(actor)) {}
|
||||
UniValue operator()(const JSONRPCRequest& jsonRequest)
|
||||
{
|
||||
UniValue val;
|
||||
|
@ -154,6 +154,11 @@ public:
|
|||
*/
|
||||
std::vector<std::string> listCommands() const;
|
||||
|
||||
/**
|
||||
* Clear all mapped command
|
||||
* used in tests
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Appends a CRPCCommand to the dispatch table.
|
||||
|
|
|
@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(spend_claim_test)
|
|||
fixture.Spend(tx5);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(!fixture.is_best_claim("test",tx5));
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
|
||||
fixture.DecrementBlocks(1);
|
||||
BOOST_CHECK(fixture.is_best_claim("test",tx5));
|
||||
|
@ -752,13 +752,13 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
BOOST_CHECK_EQUAL(val.outPoint, tx1OutPoint);
|
||||
BOOST_CHECK(fixture.haveClaim(sName1, tx7OutPoint));
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
|
||||
// Roll all the way back, make sure all txs are out of the trie
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(!fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(fixture.getMerkleHash(), hash0);
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
|
@ -768,7 +768,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(10); // 11
|
||||
|
@ -777,20 +777,20 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx7);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// Undo that block and make sure it's not in the queue
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
// Make sure it's not in the queue
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Go back to the beginning
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Test spend a claim which was just inserted into the trie
|
||||
|
@ -801,11 +801,11 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
CMutableTransaction tx4 = fixture.Spend(tx2);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
fixture.DecrementBlocks(1);
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Verify that if a claim in the queue is spent, it does not get into the trie
|
||||
|
@ -821,12 +821,12 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(fixture.haveClaimInQueue(sName2, tx2OutPoint, nThrowaway));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(3);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// Spend tx2 with tx4, and then advance to where tx2 would be inserted into the trie and verify it hasn't happened
|
||||
|
@ -834,12 +834,12 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx4);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(5);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.haveClaim(sName2, tx2OutPoint));
|
||||
|
||||
|
@ -848,14 +848,14 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.DecrementBlocks();
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.haveClaimInQueue(sName2, tx2OutPoint, nThrowaway));
|
||||
|
||||
fixture.IncrementBlocks(2);
|
||||
|
||||
BOOST_CHECK(fixture.haveClaim(sName2, tx2OutPoint));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName2, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx5OutPoint);
|
||||
|
@ -867,14 +867,14 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx4);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.haveClaim(sName2, tx2OutPoint));
|
||||
|
||||
// undo spending tx2 with tx4, and verify tx2 is back in the trie
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName2, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx5OutPoint);
|
||||
|
@ -883,7 +883,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
// roll back to the beginning
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Test undoing a spent update which updated a claim still in the queue
|
||||
|
@ -898,7 +898,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.haveClaimInQueue(sName1, tx1OutPoint, nThrowaway));
|
||||
|
||||
|
@ -909,7 +909,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.haveClaimInQueue(sName1, tx1OutPoint, nThrowaway));
|
||||
BOOST_CHECK(!fixture.haveClaim(sName1, tx1OutPoint));
|
||||
|
@ -920,34 +920,34 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
CMutableTransaction tx6 = fixture.Spend(tx3);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.haveClaim(sName1, tx3OutPoint));
|
||||
|
||||
// undo spending the update (undo tx6 spending tx3)
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// make sure the update (tx3) still goes into effect when it's supposed to
|
||||
fixture.IncrementBlocks(9);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx3OutPoint);
|
||||
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.haveClaim(sName1, tx3OutPoint));
|
||||
|
||||
// roll all the way back
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Test undoing an spent update which updated the best claim to a name
|
||||
|
@ -957,12 +957,12 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(5);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx1OutPoint);
|
||||
|
@ -971,7 +971,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx3OutPoint);
|
||||
|
@ -980,13 +980,13 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx6);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// undo spending the update (undo tx6 spending tx3)
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx3OutPoint);
|
||||
|
@ -1011,7 +1011,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
|
||||
// ensure txout 0 made it into the trie and txout 1 did not
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
|
@ -1020,14 +1020,14 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
// roll forward until tx8 output 1 gets into the trie
|
||||
fixture.IncrementBlocks(6);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
// ensure txout 1 made it into the trie and is now in control
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
|
@ -1039,7 +1039,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks();
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// make sure invalid updates don't wreak any havoc
|
||||
|
@ -1130,14 +1130,14 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
fixture.CommitTx(tx10);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// update with tx11
|
||||
fixture.CommitTx(tx11);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// roll back to before tx11
|
||||
|
@ -1148,7 +1148,7 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// roll all the way back
|
||||
|
@ -1160,13 +1160,13 @@ BOOST_AUTO_TEST_CASE(insert_update_claim_test)
|
|||
CMutableTransaction tx13 = fixture.MakeClaim(fixture.GetCoinbase(), sName3, sValue3, 1);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// roll back
|
||||
|
@ -1222,7 +1222,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
|
||||
auto* pcoinsTip = &::ChainstateActive().CoinsTip();
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx1.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1246,18 +1246,18 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.IncrementBlocks(1); // 11
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx2.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// advance until tx2 is valid
|
||||
fixture.IncrementBlocks(9); // 20
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(1); // 21
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1276,7 +1276,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.IncrementBlocks(1); // 22
|
||||
|
||||
// verify tx2 gains control
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1287,7 +1287,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
// unspend tx3, verify tx1 regains control
|
||||
fixture.DecrementBlocks(1); // 21
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1301,7 +1301,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.IncrementBlocks(1); // 22
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx7.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1324,7 +1324,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.IncrementBlocks(1); // 21
|
||||
|
||||
// Verify tx2 gains control
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1343,18 +1343,18 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.IncrementBlocks(1); // 11
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx2.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// advance until tx2 is valid
|
||||
fixture.IncrementBlocks(9); // 20
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(2); // 22
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint.hash, tx2.GetHash());
|
||||
|
@ -1373,7 +1373,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
fixture.CommitTx(tx2);
|
||||
fixture.IncrementBlocks(1); // 1
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1409,7 +1409,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
|
||||
fixture.IncrementBlocks(4); // 13
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1439,7 +1439,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims_test)
|
|||
|
||||
// roll all the way back
|
||||
fixture.DecrementBlocks(13);
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1465,7 +1465,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
|
||||
auto* pcoinsTip = &::ChainstateActive().CoinsTip();
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx1.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1478,7 +1478,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.IncrementBlocks(1); // 6
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx2.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1504,7 +1504,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.IncrementBlocks(1); // 16
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx3.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(!fixture.supportQueueEmpty());
|
||||
|
@ -1516,7 +1516,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 21
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1531,7 +1531,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx6);
|
||||
fixture.IncrementBlocks(1); // 22
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1541,7 +1541,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// undo spend
|
||||
fixture.DecrementBlocks(1); // 21
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1551,7 +1551,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll back to before tx3 is valid
|
||||
fixture.DecrementBlocks(1); // 20
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(!fixture.supportQueueEmpty());
|
||||
|
@ -1561,7 +1561,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(20); // 0
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1575,7 +1575,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.IncrementBlocks(1); // 1
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx1.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1591,7 +1591,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
|
||||
auto rootMerkleHash = fixture.getMerkleHash();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1604,7 +1604,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1); // 10
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1615,7 +1615,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// advance until tx2 is valid, verify tx1 retains control
|
||||
fixture.IncrementBlocks(3); // 13
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1627,7 +1627,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(13); // 0
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1639,7 +1639,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx2);
|
||||
fixture.IncrementBlocks(1); // 1
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1654,7 +1654,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1); // 11
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1669,7 +1669,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1); // 17
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(!fixture.supportQueueEmpty());
|
||||
|
@ -1680,7 +1680,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// advance until tx1 is valid
|
||||
fixture.IncrementBlocks(5); // 22
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(!fixture.supportQueueEmpty());
|
||||
|
@ -1692,7 +1692,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// advance until tx3 is valid
|
||||
fixture.IncrementBlocks(11); // 33
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1702,7 +1702,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(33); // 0
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1713,7 +1713,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1); // 1
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1727,7 +1727,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx2);
|
||||
fixture.IncrementBlocks(1); // 7
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1739,7 +1739,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1); // 10
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1749,7 +1749,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// advance until tx2 is valid
|
||||
fixture.IncrementBlocks(3); // 13
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1760,7 +1760,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx4);
|
||||
fixture.IncrementBlocks(1); // 14
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1770,7 +1770,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// undo spend of tx1
|
||||
fixture.DecrementBlocks(1); // 13
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1780,7 +1780,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(13); // 0
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1792,7 +1792,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1); // 1
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1801,7 +1801,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx3);
|
||||
fixture.IncrementBlocks(1); // 2
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1810,7 +1810,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
fixture.CommitTx(tx4);
|
||||
fixture.IncrementBlocks(1); // 3
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1818,7 +1818,7 @@ BOOST_AUTO_TEST_CASE(supporting_claims2_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(3);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1843,7 +1843,7 @@ BOOST_AUTO_TEST_CASE(invalid_claimid_test)
|
|||
|
||||
auto* pcoinsTip = &::ChainstateActive().CoinsTip();
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx1.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -1856,7 +1856,7 @@ BOOST_AUTO_TEST_CASE(invalid_claimid_test)
|
|||
fixture.IncrementBlocks(1); // 102
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx2.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
|
||||
// Create a tx with a bogus claimId
|
||||
|
@ -1868,7 +1868,7 @@ BOOST_AUTO_TEST_CASE(invalid_claimid_test)
|
|||
fixture.IncrementBlocks(1); // 103
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx3.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Verify it's not in the claim trie
|
||||
|
@ -1882,7 +1882,7 @@ BOOST_AUTO_TEST_CASE(invalid_claimid_test)
|
|||
fixture.IncrementBlocks(1); // 104
|
||||
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(tx4OutPoint));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
|
||||
// Verify it's not in the claim trie
|
||||
|
@ -1896,13 +1896,13 @@ BOOST_AUTO_TEST_CASE(invalid_claimid_test)
|
|||
|
||||
fixture.IncrementBlocks(101); // 205
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.haveClaim(sName, tx4OutPoint));
|
||||
|
||||
// go all the way back
|
||||
fixture.DecrementBlocks();
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(merkle_hash_single_test)
|
|||
{
|
||||
// check empty trie
|
||||
auto one = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
CClaimTrieCacheTest cc(pclaimTrie);
|
||||
CClaimTrieCacheTest cc(&::Claimtrie());
|
||||
BOOST_CHECK_EQUAL(one, cc.getMerkleHash());
|
||||
|
||||
// we cannot have leaf root node
|
||||
|
@ -108,11 +108,11 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
hash4.SetHex("c73232a755bf015f22eaa611b283ff38100f2a23fb6222e86eca363452ba0c51");
|
||||
|
||||
{
|
||||
CClaimTrieCacheTest ntState(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState(&::Claimtrie());
|
||||
ntState.insertClaimIntoTrie(std::string("test"), CClaimValue(tx1OutPoint, {}, 50, 0, 0));
|
||||
ntState.insertClaimIntoTrie(std::string("test2"), CClaimValue(tx2OutPoint, {}, 50, 0, 0));
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState.getTotalClaimsInTrie(), 2U);
|
||||
BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash1);
|
||||
|
||||
|
@ -126,12 +126,12 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash2);
|
||||
ntState.flush();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash2);
|
||||
BOOST_CHECK(ntState.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState1(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState1(&::Claimtrie());
|
||||
ntState1.removeClaimFromTrie(std::string("test"), tx1OutPoint);
|
||||
ntState1.removeClaimFromTrie(std::string("test2"), tx2OutPoint);
|
||||
ntState1.removeClaimFromTrie(std::string("test"), tx3OutPoint);
|
||||
|
@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
BOOST_CHECK_EQUAL(ntState1.getMerkleHash(), hash0);
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState2(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState2(&::Claimtrie());
|
||||
ntState2.insertClaimIntoTrie(std::string("abab"), CClaimValue(tx6OutPoint, {}, 50, 0, 200));
|
||||
ntState2.removeClaimFromTrie(std::string("test"), tx1OutPoint);
|
||||
|
||||
|
@ -148,50 +148,50 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
|
||||
ntState2.flush();
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState2.getMerkleHash(), hash3);
|
||||
BOOST_CHECK(ntState2.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState3(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState3(&::Claimtrie());
|
||||
ntState3.insertClaimIntoTrie(std::string("test"), CClaimValue(tx1OutPoint, {}, 50, 0, 0));
|
||||
BOOST_CHECK_EQUAL(ntState3.getMerkleHash(), hash4);
|
||||
ntState3.flush();
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState3.getMerkleHash(), hash4);
|
||||
BOOST_CHECK(ntState3.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState4(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState4(&::Claimtrie());
|
||||
ntState4.removeClaimFromTrie(std::string("abab"), tx6OutPoint);
|
||||
BOOST_CHECK_EQUAL(ntState4.getMerkleHash(), hash2);
|
||||
ntState4.flush();
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState4.getMerkleHash(), hash2);
|
||||
BOOST_CHECK(ntState4.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState5(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState5(&::Claimtrie());
|
||||
ntState5.removeClaimFromTrie(std::string("test"), tx3OutPoint);
|
||||
|
||||
BOOST_CHECK_EQUAL(ntState5.getMerkleHash(), hash2);
|
||||
ntState5.flush();
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState5.getMerkleHash(), hash2);
|
||||
BOOST_CHECK(ntState5.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState6(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState6(&::Claimtrie());
|
||||
ntState6.insertClaimIntoTrie(std::string("test"), CClaimValue(tx3OutPoint, {}, 50, 1, 1));
|
||||
|
||||
BOOST_CHECK_EQUAL(ntState6.getMerkleHash(), hash2);
|
||||
ntState6.flush();
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState6.getMerkleHash(), hash2);
|
||||
BOOST_CHECK(ntState6.checkConsistency());
|
||||
}
|
||||
{
|
||||
CClaimTrieCacheTest ntState7(pclaimTrie);
|
||||
CClaimTrieCacheTest ntState7(&::Claimtrie());
|
||||
ntState7.removeClaimFromTrie(std::string("test"), tx3OutPoint);
|
||||
ntState7.removeClaimFromTrie(std::string("test"), tx1OutPoint);
|
||||
ntState7.removeClaimFromTrie(std::string("tes"), tx4OutPoint);
|
||||
|
@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
|
||||
BOOST_CHECK_EQUAL(ntState7.getMerkleHash(), hash0);
|
||||
ntState7.flush();
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK_EQUAL(ntState7.getMerkleHash(), hash0);
|
||||
BOOST_CHECK(ntState7.checkConsistency());
|
||||
}
|
||||
|
@ -208,8 +208,8 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
|
|||
BOOST_AUTO_TEST_CASE(basic_insertion_info_test)
|
||||
{
|
||||
// test basic claim insertions and that get methods retreives information properly
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
CClaimTrieCacheTest ctc(pclaimTrie);
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
CClaimTrieCacheTest ctc(&::Claimtrie());
|
||||
|
||||
// create and insert claim
|
||||
auto hash0 = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(basic_insertion_info_test)
|
|||
|
||||
//BOOST_AUTO_TEST_CASE(recursive_prune_test)
|
||||
//{
|
||||
// CClaimTrieCacheTest cc(pclaimTrie);
|
||||
// CClaimTrieCacheTest cc(&::Claimtrie());
|
||||
// BOOST_CHECK_EQUAL(0, cc.getTotalClaimsInTrie());
|
||||
//
|
||||
// COutPoint outpoint;
|
||||
|
@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(trie_stays_consistent_test)
|
|||
"goodness", "goodnight", "goodnatured", "goods", "go", "goody", "goo"
|
||||
};
|
||||
|
||||
CClaimTrieCacheTest cache(pclaimTrie);
|
||||
CClaimTrieCacheTest cache(&::Claimtrie());
|
||||
CClaimValue value;
|
||||
|
||||
for (auto& name: names) {
|
||||
|
@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(trie_stays_consistent_test)
|
|||
cache.flush();
|
||||
BOOST_CHECK(cache.checkConsistency());
|
||||
}
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(verify_basic_serialization)
|
||||
|
|
|
@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
COutPoint tx1OutPoint(tx1.GetHash(), 0);
|
||||
fixture.IncrementBlocks(1, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -355,47 +355,47 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
|
||||
fixture.IncrementBlocks(79); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// roll forward a bit and then roll back to before the expiration event. verify the claim is reinserted. verify the expiration event is scheduled again.
|
||||
fixture.IncrementBlocks(20); // 101
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
fixture.DecrementBlocks(21); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
// advance until the expiration event occurs. verify the expiration event occurs on time.
|
||||
fixture.IncrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// roll back to before the expiration event. verify the claim is reinserted. verify the expiration event is scheduled again.
|
||||
fixture.DecrementBlocks(2); // 79
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
// roll back some more.
|
||||
fixture.DecrementBlocks(39); // 40
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -403,27 +403,27 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
CMutableTransaction tx2 = fixture.Spend(tx1);
|
||||
fixture.IncrementBlocks(1); // 41
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// roll back the spend. verify the expiration event is returned.
|
||||
fixture.DecrementBlocks(1); // 40
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
// advance until the expiration event occurs. verify the event occurs on time.
|
||||
fixture.IncrementBlocks(40); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -431,42 +431,42 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
fixture.CommitTx(tx2);
|
||||
fixture.IncrementBlocks(1); // 82
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// undo the spend. verify everything remains empty.
|
||||
fixture.DecrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// roll back to before the expiration event. verify the claim is reinserted. verify the expiration event is scheduled again.
|
||||
fixture.DecrementBlocks(1); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
// verify the expiration event happens at the right time again
|
||||
fixture.IncrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
// roll back to before the expiration event. verify it gets reinserted and expiration gets scheduled.
|
||||
fixture.DecrementBlocks(1); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
// roll all the way back. verify the claim is removed and the expiration event is removed.
|
||||
fixture.DecrementBlocks(); // 0
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
fixture.CommitTx(tx1);
|
||||
fixture.IncrementBlocks(1, true); // 1
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
COutPoint tx3OutPoint(tx3.GetHash(), 0);
|
||||
fixture.IncrementBlocks(1); // 6
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
|
@ -500,7 +500,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 11
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName, val));
|
||||
|
@ -513,7 +513,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
// advance again until tx is valid
|
||||
fixture.IncrementBlocks(1); // 11
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName, val));
|
||||
|
@ -523,13 +523,13 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
// advance until the expiration event occurs. verify the expiration event occurs on time.
|
||||
fixture.IncrementBlocks(69, true); // 80
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
|
||||
fixture.IncrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName, val));
|
||||
|
@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
// roll back to when tx1 and tx3 are in the trie and tx1 is winning
|
||||
fixture.DecrementBlocks(); // 11
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.expirationQueueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName, val));
|
||||
|
@ -552,7 +552,7 @@ BOOST_AUTO_TEST_CASE(claim_expiration_test)
|
|||
|
||||
// roll all the way back
|
||||
fixture.DecrementBlocks();
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.expirationQueueEmpty());
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
auto* pcoinsTip = &::ChainstateActive().CoinsTip();
|
||||
BOOST_CHECK(pcoinsTip->HaveCoin(COutPoint(tx1.GetHash(), 0)));
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
CMutableTransaction tx3 = fixture.MakeSupport(fixture.GetCoinbase(), tx1, sName, 5);
|
||||
fixture.IncrementBlocks(1); // 2, expires at 82
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(), sName, sValue2, 5);
|
||||
fixture.IncrementBlocks(1); // 22, activating in (22 - 2) / 1 = 20block (but not then active because support still holds tx1 up)
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -609,7 +609,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
// Advance until tx2 is valid
|
||||
fixture.IncrementBlocks(20); // 42
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(!fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -617,7 +617,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 43
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -631,7 +631,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 104
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -642,7 +642,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
// Advance until the support expires
|
||||
fixture.IncrementBlocks(37); // 81
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -650,7 +650,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 82
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -662,7 +662,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
// undo the block, make sure control goes back
|
||||
fixture.DecrementBlocks(1); // 81
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
// redo the block, make sure it expires again
|
||||
fixture.IncrementBlocks(1); // 82
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -686,7 +686,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.DecrementBlocks(19); // 63
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -699,7 +699,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
blocks_to_invalidate.push_back(::ChainActive().Tip()->GetBlockHash());
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -708,7 +708,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(20); // 84
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.DecrementBlocks(21); // 63
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -728,7 +728,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(18); // 81
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(!fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -737,7 +737,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
|
||||
fixture.IncrementBlocks(1); // 82
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
@ -747,7 +747,7 @@ BOOST_AUTO_TEST_CASE(expiring_supports_test)
|
|||
// roll all the way back
|
||||
fixture.DecrementBlocks(82);
|
||||
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.supportEmpty());
|
||||
BOOST_CHECK(fixture.supportQueueEmpty());
|
||||
|
|
|
@ -74,7 +74,7 @@ BlockAssembler AssemblerForTest()
|
|||
return BlockAssembler(Params(), options);
|
||||
}
|
||||
|
||||
ClaimTrieChainFixture::ClaimTrieChainFixture() : CClaimTrieCache(pclaimTrie),
|
||||
ClaimTrieChainFixture::ClaimTrieChainFixture() : CClaimTrieCache(&::Claimtrie()),
|
||||
unique_block_counter(0), normalization_original(-1), expirationForkHeight(-1), forkhash_original(-1),
|
||||
minRemovalWorkaroundHeight(-1), maxRemovalWorkaroundHeight(-1)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,7 @@ BOOST_AUTO_TEST_CASE(value_proof_test)
|
|||
// create a claim. verify the expiration event has been scheduled.
|
||||
fixture.IncrementBlocks(5, true);
|
||||
|
||||
BOOST_CHECK(!pclaimTrie->empty());
|
||||
BOOST_CHECK(!::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
BOOST_CHECK(fixture.getInfoForName(sName1, val));
|
||||
BOOST_CHECK_EQUAL(val.outPoint, tx1OutPoint);
|
||||
|
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(value_proof_test)
|
|||
BOOST_CHECK_EQUAL(proof.hasValue, false);
|
||||
|
||||
fixture.DecrementBlocks();
|
||||
BOOST_CHECK(pclaimTrie->empty());
|
||||
BOOST_CHECK(::Claimtrie().empty());
|
||||
BOOST_CHECK(fixture.queueEmpty());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ BOOST_FIXTURE_TEST_SUITE(claimtrienormalization_tests, RegTestingSetup)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(normalization_only)
|
||||
{
|
||||
CClaimTrieCache ccache(pclaimTrie);
|
||||
auto ccache = ::ClaimtrieCache();
|
||||
|
||||
// basic ASCII casing tests
|
||||
BOOST_CHECK_EQUAL("test", ccache.normalizeClaimName("TESt", true));
|
||||
|
@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(claimtriecache_normalization)
|
|||
BOOST_CHECK(nval1.nHeight == currentHeight);
|
||||
BOOST_CHECK(lookupClaim == nval1);
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CBlockIndex* pindex = ::ChainActive().Tip();
|
||||
CCoinsViewCache coins(&::ChainstateActive().CoinsTip());
|
||||
|
||||
|
@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(normalization_removal_test)
|
|||
CMutableTransaction sx1 = fixture.MakeSupport(fixture.GetCoinbase(), tx1, "AB", 1);
|
||||
CMutableTransaction sx2 = fixture.MakeSupport(fixture.GetCoinbase(), tx2, "Ab", 1);
|
||||
|
||||
CClaimTrieCache cache(pclaimTrie);
|
||||
auto cache = ::ClaimtrieCache();
|
||||
int height = ::ChainActive().Height() + 1;
|
||||
cache.addClaim("AB", COutPoint(tx1.GetHash(), 0), ClaimIdHash(tx1.GetHash(), 0), 1, height);
|
||||
cache.addClaim("Ab", COutPoint(tx2.GetHash(), 0), ClaimIdHash(tx2.GetHash(), 0), 2, height);
|
||||
|
|
|
@ -411,8 +411,8 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
|
|||
BOOST_CHECK(stack.back()->SpendCoin(utxod->first));
|
||||
// restore inputs
|
||||
if (!tx.IsCoinBase()) {
|
||||
const COutPoint &out = tx.vin[0].prevout;
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
const auto &out = tx.vin[0].prevout;
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
ApplyTxInUndo(0, undo, *(stack.back()), trieCache, out);
|
||||
}
|
||||
// Store as a candidate for reconnection
|
||||
|
|
|
@ -120,15 +120,6 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
|||
g_chainstate = MakeUnique<CChainState>();
|
||||
::ChainstateActive().InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
auto &consensus = chainparams.GetConsensus();
|
||||
pclaimTrie = new CClaimTrie(20000000U, true, 0, GetDataDir().string(),
|
||||
consensus.nNormalizedNameForkHeight,
|
||||
consensus.nMinRemovalWorkaroundHeight,
|
||||
consensus.nMaxRemovalWorkaroundHeight,
|
||||
consensus.nOriginalClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationForkHeight,
|
||||
consensus.nAllClaimsInMerkleForkHeight, 1);
|
||||
assert(!::ChainstateActive().CanFlushToDisk());
|
||||
::ChainstateActive().InitCoinsCache();
|
||||
assert(::ChainstateActive().CanFlushToDisk());
|
||||
|
@ -154,8 +145,11 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
|||
}
|
||||
}
|
||||
|
||||
extern std::unique_ptr<CClaimTrie> g_claimtrie;
|
||||
|
||||
TestingSetup::~TestingSetup()
|
||||
{
|
||||
tableRPC.clear();
|
||||
threadGroup.interrupt_all();
|
||||
threadGroup.join_all();
|
||||
GetMainSignals().FlushBackgroundCallbacks();
|
||||
|
@ -164,8 +158,8 @@ TestingSetup::~TestingSetup()
|
|||
g_banman.reset();
|
||||
UnloadBlockIndex();
|
||||
g_chainstate.reset();
|
||||
g_claimtrie.reset();
|
||||
pblocktree.reset();
|
||||
delete pclaimTrie;
|
||||
}
|
||||
|
||||
TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
|
||||
|
|
|
@ -88,6 +88,7 @@ BlockManager g_blockman;
|
|||
} // anon namespace
|
||||
|
||||
std::unique_ptr<CChainState> g_chainstate;
|
||||
std::unique_ptr<CClaimTrie> g_claimtrie;
|
||||
|
||||
CChainState& ChainstateActive() {
|
||||
assert(g_chainstate);
|
||||
|
@ -98,6 +99,32 @@ CChain& ChainActive() {
|
|||
return g_chainstate->m_chain;
|
||||
}
|
||||
|
||||
CClaimTrie& Claimtrie() {
|
||||
if (!g_claimtrie) {
|
||||
int64_t nTotalCache = gArgs.GetArg("-dbcache", nDefaultDbCache) << 20;
|
||||
auto fReindexChainState = gArgs.GetBoolArg("-reindex-chainstate", false);
|
||||
auto fReindex = gArgs.GetBoolArg("-reindex", false);
|
||||
auto& consensus = Params().GetConsensus();
|
||||
g_claimtrie = std::make_unique<CClaimTrie>(nTotalCache / 4,
|
||||
fReindex || fReindexChainState, 0,
|
||||
GetDataDir().string(),
|
||||
consensus.nNormalizedNameForkHeight,
|
||||
consensus.nMinRemovalWorkaroundHeight,
|
||||
consensus.nMaxRemovalWorkaroundHeight,
|
||||
consensus.nOriginalClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationTime,
|
||||
consensus.nExtendedClaimExpirationForkHeight,
|
||||
consensus.nAllClaimsInMerkleForkHeight,
|
||||
Params().NetworkIDString() == CBaseChainParams::MAIN ? 32 : 1);
|
||||
};
|
||||
return *g_claimtrie;
|
||||
}
|
||||
|
||||
CClaimTrieCache ClaimtrieCache() {
|
||||
return CClaimTrieCache(&::Claimtrie());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mutex to guard access to validation specific variables, such as reading
|
||||
* or changing the chainstate.
|
||||
|
@ -186,8 +213,6 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
|||
}
|
||||
|
||||
std::unique_ptr<CBlockTreeDB> pblocktree;
|
||||
// FIXME: make unique_ptr
|
||||
CClaimTrie *pclaimTrie = nullptr;
|
||||
|
||||
// See definition for documentation
|
||||
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
|
||||
|
@ -2467,7 +2492,7 @@ bool CChainState::FlushStateToDisk(
|
|||
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
||||
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!").translated, CClientUIInterface::MSG_NOPREFIX);
|
||||
}
|
||||
if (mode == FlushStateMode::ALWAYS && !pclaimTrie->SyncToDisk())
|
||||
if (mode == FlushStateMode::ALWAYS && !::Claimtrie().SyncToDisk())
|
||||
return state.Error("Failed to write to claim trie database");
|
||||
// Flush the chainstate (which may refer to block index entries).
|
||||
if (!CoinsTip().Flush(mode == FlushStateMode::ALWAYS))
|
||||
|
@ -2605,7 +2630,7 @@ bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& cha
|
|||
int64_t nStart = GetTimeMicros();
|
||||
{
|
||||
CCoinsViewCache view(&CoinsTip());
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
assert(view.GetBestBlock() == pindexDelete->GetBlockHash());
|
||||
if (DisconnectBlock(block, pindexDelete, view, trieCache) != DISCONNECT_OK)
|
||||
return error("DisconnectTip(): DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString());
|
||||
|
@ -2736,7 +2761,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
|
|||
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * MILLI, nTimeReadFromDisk * MICRO);
|
||||
{
|
||||
CCoinsViewCache view(&CoinsTip());
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view, trieCache, chainparams);
|
||||
GetMainSignals().BlockChecked(blockConnecting, state);
|
||||
if (!rv) {
|
||||
|
@ -3973,7 +3998,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
|
|||
AssertLockHeld(cs_main);
|
||||
assert(pindexPrev && pindexPrev == ::ChainActive().Tip());
|
||||
CCoinsViewCache viewNew(&::ChainstateActive().CoinsTip());
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
uint256 block_hash(block.GetHash());
|
||||
CBlockIndex indexDummy(block);
|
||||
indexDummy.pprev = pindexPrev;
|
||||
|
@ -4373,7 +4398,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
|
|||
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
|
||||
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
|
||||
CCoinsViewCache coins(coinsview);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
CBlockIndex* pindex;
|
||||
CBlockIndex* pindexFailure = nullptr;
|
||||
int nGoodTransactions = 0;
|
||||
|
@ -4489,7 +4514,7 @@ bool CChainState::ReplayBlocks(const CChainParams& params)
|
|||
|
||||
CCoinsView& db = this->CoinsDB();
|
||||
CCoinsViewCache cache(&db);
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
|
||||
std::vector<uint256> hashHeads = db.GetHeadBlocks();
|
||||
if (hashHeads.empty()) return true; // We're already in a consistent state.
|
||||
|
|
|
@ -51,6 +51,12 @@ struct DisconnectedBlockTransactions;
|
|||
struct PrecomputedTransactionData;
|
||||
struct LockPoints;
|
||||
|
||||
/** access claimtrie singleton */
|
||||
CClaimTrie& Claimtrie();
|
||||
|
||||
/** create claimtrie cache instance */
|
||||
CClaimTrieCache ClaimtrieCache();
|
||||
|
||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
||||
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
||||
/** Default for -limitancestorcount, max number of in-mempool ancestors */
|
||||
|
|
|
@ -611,7 +611,7 @@ void ListNameClaims(interfaces::Chain::Lock& locked_chain, const CWalletTx& wtx,
|
|||
entry.pushKV("vout", s.vout);
|
||||
entry.pushKV("fee", ValueFromAmount(nFee));
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
|
||||
if (auto pindex = LookupBlockIndex(wtx.m_confirm.hashBlock))
|
||||
{
|
||||
|
@ -757,7 +757,7 @@ UniValue supportclaim(const JSONRPCRequest& request)
|
|||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
auto trieCache = ::ClaimtrieCache();
|
||||
auto csToName = trieCache.getClaimsForName(sName);
|
||||
if (csToName.claimsNsupports.empty())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Unable to find a claim named %s", sName));
|
||||
|
|
Loading…
Add table
Reference in a new issue