mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 16:53:52 +02:00
Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats
The indexing codepath logic in node/coinstats.cpp is simple enough to be moved into CoinStatsIndex::LookUpStats, avoiding an additional layer of function calls. Callers are modified accordingly. Also, add 2 missed BOOST_CHECKs to the coinstatsindex_initial_sync unit test.
This commit is contained in:
@@ -33,7 +33,6 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
||||
{
|
||||
CoinStatsIndex coin_stats_index{1 << 20, true};
|
||||
|
||||
CCoinsStats coin_stats{};
|
||||
const CBlockIndex* block_index;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
@@ -41,7 +40,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
||||
}
|
||||
|
||||
// CoinStatsIndex should not be found before it is started.
|
||||
BOOST_CHECK(!coin_stats_index.LookUpStats(block_index, coin_stats));
|
||||
BOOST_CHECK(!coin_stats_index.LookUpStats(block_index));
|
||||
|
||||
// BlockUntilSyncedToCurrentChain should return false before CoinStatsIndex
|
||||
// is started.
|
||||
@@ -57,10 +56,10 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
||||
LOCK(cs_main);
|
||||
genesis_block_index = m_node.chainman->ActiveChain().Genesis();
|
||||
}
|
||||
BOOST_CHECK(coin_stats_index.LookUpStats(genesis_block_index, coin_stats));
|
||||
BOOST_CHECK(coin_stats_index.LookUpStats(genesis_block_index));
|
||||
|
||||
// Check that CoinStatsIndex updates with new blocks.
|
||||
coin_stats_index.LookUpStats(block_index, coin_stats);
|
||||
BOOST_CHECK(coin_stats_index.LookUpStats(block_index));
|
||||
|
||||
const CScript script_pub_key{CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG};
|
||||
std::vector<CMutableTransaction> noTxns;
|
||||
@@ -69,13 +68,12 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
||||
// Let the CoinStatsIndex to catch up again.
|
||||
BOOST_CHECK(coin_stats_index.BlockUntilSyncedToCurrentChain());
|
||||
|
||||
CCoinsStats new_coin_stats{};
|
||||
const CBlockIndex* new_block_index;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
new_block_index = m_node.chainman->ActiveChain().Tip();
|
||||
}
|
||||
coin_stats_index.LookUpStats(new_block_index, new_coin_stats);
|
||||
BOOST_CHECK(coin_stats_index.LookUpStats(new_block_index));
|
||||
|
||||
BOOST_CHECK(block_index != new_block_index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user