mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
init: add utxo snapshot detection
Add functionality for activating a snapshot-based chainstate if one is detected on-disk. Also cautiously initialize chainstate cache usages so that we don't somehow blow past our cache allowances during initialization, then rebalance at the end of init. Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
|
||||
// Create a snapshot-based chainstate.
|
||||
//
|
||||
const uint256 snapshot_blockhash = GetRandHash();
|
||||
Chainstate& c2 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(
|
||||
Chainstate& c2 = WITH_LOCK(::cs_main, return manager.ActivateExistingSnapshot(
|
||||
&mempool, snapshot_blockhash));
|
||||
chainstates.push_back(&c2);
|
||||
|
||||
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
||||
|
||||
// Create a snapshot-based chainstate.
|
||||
//
|
||||
Chainstate& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
|
||||
Chainstate& c2 = WITH_LOCK(cs_main, return manager.ActivateExistingSnapshot(&mempool, GetRandHash()));
|
||||
chainstates.push_back(&c2);
|
||||
c2.InitCoinsDB(
|
||||
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
||||
@@ -383,7 +383,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(expected_assumed_valid, num_assumed_valid);
|
||||
|
||||
Chainstate& cs2 = WITH_LOCK(::cs_main,
|
||||
return chainman.InitializeChainstate(&mempool, GetRandHash()));
|
||||
return chainman.ActivateExistingSnapshot(&mempool, GetRandHash()));
|
||||
|
||||
reload_all_block_indexes();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user