mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
scripted-diff: rename CChainState -> Chainstate
-BEGIN VERIFY SCRIPT- sed -i 's/CChainState/Chainstate/g' $(git grep -l CChainState ':(exclude)doc/release-notes*') -END VERIFY SCRIPT- Co-authored-by: MacroFake <falke.marco@gmail.com>
This commit is contained in:
parent
37095c7dc4
commit
00eeb31c76
33 changed files with 154 additions and 154 deletions
|
@ -41,7 +41,7 @@ be of use.
|
||||||
|
|
||||||
Chainstate within the system goes through a number of phases when UTXO snapshots are
|
Chainstate within the system goes through a number of phases when UTXO snapshots are
|
||||||
used, as managed by `ChainstateManager`. At various points there can be multiple
|
used, as managed by `ChainstateManager`. At various points there can be multiple
|
||||||
`CChainState` objects in existence to facilitate both maintaining the network tip and
|
`Chainstate` objects in existence to facilitate both maintaining the network tip and
|
||||||
performing historical validation of the assumed-valid chain.
|
performing historical validation of the assumed-valid chain.
|
||||||
|
|
||||||
It is worth noting that though there are multiple separate chainstates, those
|
It is worth noting that though there are multiple separate chainstates, those
|
||||||
|
@ -53,7 +53,7 @@ data.
|
||||||
|
|
||||||
### "Normal" operation via initial block download
|
### "Normal" operation via initial block download
|
||||||
|
|
||||||
`ChainstateManager` manages a single CChainState object, for which
|
`ChainstateManager` manages a single Chainstate object, for which
|
||||||
`m_snapshot_blockhash` is null. This chainstate is (maybe obviously)
|
`m_snapshot_blockhash` is null. This chainstate is (maybe obviously)
|
||||||
considered active. This is the "traditional" mode of operation for bitcoind.
|
considered active. This is the "traditional" mode of operation for bitcoind.
|
||||||
|
|
||||||
|
|
|
@ -962,7 +962,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(...)
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
// validation.h
|
// validation.h
|
||||||
class CChainState
|
class Chainstate
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
...
|
...
|
||||||
|
@ -983,7 +983,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// validation.cpp
|
// validation.cpp
|
||||||
bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
|
bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
AssertLockNotHeld(m_chainstate_mutex);
|
AssertLockNotHeld(m_chainstate_mutex);
|
||||||
AssertLockNotHeld(::cs_main);
|
AssertLockNotHeld(::cs_main);
|
||||||
|
|
|
@ -104,7 +104,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
|
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!chainstate->ActivateBestChain(state, nullptr)) {
|
if (!chainstate->ActivateBestChain(state, nullptr)) {
|
||||||
std::cerr << "Failed to connect best block (" << state.ToString() << ")" << std::endl;
|
std::cerr << "Failed to connect best block (" << state.ToString() << ")" << std::endl;
|
||||||
|
@ -253,7 +253,7 @@ epilogue:
|
||||||
GetMainSignals().FlushBackgroundCallbacks();
|
GetMainSignals().FlushBackgroundCallbacks();
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
if (chainstate->CanFlushToDisk()) {
|
if (chainstate->CanFlushToDisk()) {
|
||||||
chainstate->ForceFlushStateToDisk();
|
chainstate->ForceFlushStateToDisk();
|
||||||
chainstate->ResetCoinsViews();
|
chainstate->ResetCoinsViews();
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
class CBlock;
|
class CBlock;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
class Chain;
|
class Chain;
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
@ -94,7 +94,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<interfaces::Chain> m_chain;
|
std::unique_ptr<interfaces::Chain> m_chain;
|
||||||
CChainState* m_chainstate{nullptr};
|
Chainstate* m_chainstate{nullptr};
|
||||||
|
|
||||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;
|
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ void Shutdown(NodeContext& node)
|
||||||
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
|
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
|
||||||
if (node.chainman) {
|
if (node.chainman) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
for (CChainState* chainstate : node.chainman->GetAll()) {
|
for (Chainstate* chainstate : node.chainman->GetAll()) {
|
||||||
if (chainstate->CanFlushToDisk()) {
|
if (chainstate->CanFlushToDisk()) {
|
||||||
chainstate->ForceFlushStateToDisk();
|
chainstate->ForceFlushStateToDisk();
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ void Shutdown(NodeContext& node)
|
||||||
|
|
||||||
if (node.chainman) {
|
if (node.chainman) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
for (CChainState* chainstate : node.chainman->GetAll()) {
|
for (Chainstate* chainstate : node.chainman->GetAll()) {
|
||||||
if (chainstate->CanFlushToDisk()) {
|
if (chainstate->CanFlushToDisk()) {
|
||||||
chainstate->ForceFlushStateToDisk();
|
chainstate->ForceFlushStateToDisk();
|
||||||
chainstate->ResetCoinsViews();
|
chainstate->ResetCoinsViews();
|
||||||
|
@ -1532,7 +1532,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
if (fPruneMode) {
|
if (fPruneMode) {
|
||||||
if (!fReindex) {
|
if (!fReindex) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
uiInterface.InitMessage(_("Pruning blockstore…").translated);
|
uiInterface.InitMessage(_("Pruning blockstore…").translated);
|
||||||
chainstate->PruneAndFlush();
|
chainstate->PruneAndFlush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace kernel {
|
||||||
|
|
||||||
static const uint64_t MEMPOOL_DUMP_VERSION = 1;
|
static const uint64_t MEMPOOL_DUMP_VERSION = 1;
|
||||||
|
|
||||||
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, CChainState& active_chainstate, FopenFn mockable_fopen_function)
|
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, FopenFn mockable_fopen_function)
|
||||||
{
|
{
|
||||||
if (load_path.empty()) return false;
|
if (load_path.empty()) return false;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
|
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
@ -19,7 +19,7 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path,
|
||||||
|
|
||||||
/** Load the mempool from disk. */
|
/** Load the mempool from disk. */
|
||||||
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path,
|
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path,
|
||||||
CChainState& active_chainstate,
|
Chainstate& active_chainstate,
|
||||||
fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen);
|
fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen);
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
|
|
|
@ -882,7 +882,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||||
// We can't hold cs_main during ActivateBestChain even though we're accessing
|
// We can't hold cs_main during ActivateBestChain even though we're accessing
|
||||||
// the chainman unique_ptrs since ABC requires us not to be holding cs_main, so retrieve
|
// the chainman unique_ptrs since ABC requires us not to be holding cs_main, so retrieve
|
||||||
// the relevant pointers before the ABC call.
|
// the relevant pointers before the ABC call.
|
||||||
for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
|
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!chainstate->ActivateBestChain(state, nullptr)) {
|
if (!chainstate->ActivateBestChain(state, nullptr)) {
|
||||||
LogPrintf("Failed to connect best block (%s)\n", state.ToString());
|
LogPrintf("Failed to connect best block (%s)\n", state.ToString());
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CBlockFileInfo;
|
||||||
class CBlockUndo;
|
class CBlockUndo;
|
||||||
class CChain;
|
class CChain;
|
||||||
class CChainParams;
|
class CChainParams;
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
struct CCheckpointData;
|
struct CCheckpointData;
|
||||||
struct FlatFilePos;
|
struct FlatFilePos;
|
||||||
|
@ -75,12 +75,12 @@ struct PruneLockInfo {
|
||||||
* Maintains a tree of blocks (stored in `m_block_index`) which is consulted
|
* Maintains a tree of blocks (stored in `m_block_index`) which is consulted
|
||||||
* to determine where the most-work tip is.
|
* to determine where the most-work tip is.
|
||||||
*
|
*
|
||||||
* This data is used mostly in `CChainState` - information about, e.g.,
|
* This data is used mostly in `Chainstate` - information about, e.g.,
|
||||||
* candidate tips is not maintained here.
|
* candidate tips is not maintained here.
|
||||||
*/
|
*/
|
||||||
class BlockManager
|
class BlockManager
|
||||||
{
|
{
|
||||||
friend CChainState;
|
friend Chainstate;
|
||||||
friend ChainstateManager;
|
friend ChainstateManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace node {
|
||||||
ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
|
ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
|
||||||
const ChainstateLoadOptions& options)
|
const ChainstateLoadOptions& options)
|
||||||
{
|
{
|
||||||
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
auto is_coinsview_empty = [&](Chainstate* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
|
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
|
||||||
// At this point we're either in reindex or we've loaded a useful
|
// At this point we're either in reindex or we've loaded a useful
|
||||||
// block tree into BlockIndex()!
|
// block tree into BlockIndex()!
|
||||||
|
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
chainstate->InitCoinsDB(
|
chainstate->InitCoinsDB(
|
||||||
/*cache_size_bytes=*/cache_sizes.coins_db,
|
/*cache_size_bytes=*/cache_sizes.coins_db,
|
||||||
/*in_memory=*/options.coins_db_in_memory,
|
/*in_memory=*/options.coins_db_in_memory,
|
||||||
|
@ -140,7 +140,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
|
||||||
if (!options.reindex) {
|
if (!options.reindex) {
|
||||||
auto chainstates{chainman.GetAll()};
|
auto chainstates{chainman.GetAll()};
|
||||||
if (std::any_of(chainstates.begin(), chainstates.end(),
|
if (std::any_of(chainstates.begin(), chainstates.end(),
|
||||||
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
|
[](const Chainstate* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
|
||||||
return {ChainstateLoadStatus::FAILURE, strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."),
|
return {ChainstateLoadStatus::FAILURE, strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."),
|
||||||
chainman.GetConsensus().SegwitHeight)};
|
chainman.GetConsensus().SegwitHeight)};
|
||||||
};
|
};
|
||||||
|
@ -151,13 +151,13 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
|
||||||
|
|
||||||
ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options)
|
ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options)
|
||||||
{
|
{
|
||||||
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
auto is_coinsview_empty = [&](Chainstate* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
|
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
if (!is_coinsview_empty(chainstate)) {
|
if (!is_coinsview_empty(chainstate)) {
|
||||||
const CBlockIndex* tip = chainstate->m_chain.Tip();
|
const CBlockIndex* tip = chainstate->m_chain.Tip();
|
||||||
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
|
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ BlockAssembler::Options::Options()
|
||||||
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
|
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options)
|
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
|
||||||
: chainparams{chainstate.m_chainman.GetParams()},
|
: chainparams{chainstate.m_chainman.GetParams()},
|
||||||
m_mempool(mempool),
|
m_mempool(mempool),
|
||||||
m_chainstate(chainstate)
|
m_chainstate(chainstate)
|
||||||
|
@ -87,7 +87,7 @@ static BlockAssembler::Options DefaultOptions()
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool)
|
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool)
|
||||||
: BlockAssembler(chainstate, mempool, DefaultOptions()) {}
|
: BlockAssembler(chainstate, mempool, DefaultOptions()) {}
|
||||||
|
|
||||||
void BlockAssembler::resetBlock()
|
void BlockAssembler::resetBlock()
|
||||||
|
|
|
@ -148,7 +148,7 @@ private:
|
||||||
|
|
||||||
const CChainParams& chainparams;
|
const CChainParams& chainparams;
|
||||||
const CTxMemPool* const m_mempool;
|
const CTxMemPool* const m_mempool;
|
||||||
CChainState& m_chainstate;
|
Chainstate& m_chainstate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Options {
|
struct Options {
|
||||||
|
@ -157,8 +157,8 @@ public:
|
||||||
CFeeRate blockMinFeeRate;
|
CFeeRate blockMinFeeRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool);
|
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
|
||||||
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options);
|
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);
|
||||||
|
|
||||||
/** Construct a new block template with coinbase to scriptPubKeyIn */
|
/** Construct a new block template with coinbase to scriptPubKeyIn */
|
||||||
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
|
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
//! Metadata describing a serialized version of a UTXO set from which an
|
//! Metadata describing a serialized version of a UTXO set from which an
|
||||||
//! assumeutxo CChainState can be constructed.
|
//! assumeutxo Chainstate can be constructed.
|
||||||
class SnapshotMetadata
|
class SnapshotMetadata
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -767,7 +767,7 @@ static RPCHelpMan pruneblockchain()
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
CChain& active_chain = active_chainstate.m_chain;
|
CChain& active_chain = active_chainstate.m_chain;
|
||||||
|
|
||||||
int heightParam = request.params[0].getInt<int>();
|
int heightParam = request.params[0].getInt<int>();
|
||||||
|
@ -908,7 +908,7 @@ static RPCHelpMan gettxoutsetinfo()
|
||||||
|
|
||||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
ChainstateManager& chainman = EnsureChainman(node);
|
ChainstateManager& chainman = EnsureChainman(node);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
active_chainstate.ForceFlushStateToDisk();
|
active_chainstate.ForceFlushStateToDisk();
|
||||||
|
|
||||||
CCoinsView* coins_view;
|
CCoinsView* coins_view;
|
||||||
|
@ -1048,7 +1048,7 @@ static RPCHelpMan gettxout()
|
||||||
fMempool = request.params[2].get_bool();
|
fMempool = request.params[2].get_bool();
|
||||||
|
|
||||||
Coin coin;
|
Coin coin;
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();
|
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();
|
||||||
|
|
||||||
if (fMempool) {
|
if (fMempool) {
|
||||||
|
@ -1105,7 +1105,7 @@ static RPCHelpMan verifychain()
|
||||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
return CVerifyDB().VerifyDB(
|
return CVerifyDB().VerifyDB(
|
||||||
active_chainstate, chainman.GetParams().GetConsensus(), active_chainstate.CoinsTip(), check_level, check_depth);
|
active_chainstate, chainman.GetParams().GetConsensus(), active_chainstate.CoinsTip(), check_level, check_depth);
|
||||||
},
|
},
|
||||||
|
@ -1233,7 +1233,7 @@ RPCHelpMan getblockchaininfo()
|
||||||
const ArgsManager& args{EnsureAnyArgsman(request.context)};
|
const ArgsManager& args{EnsureAnyArgsman(request.context)};
|
||||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
|
|
||||||
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
|
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
|
||||||
const int height{tip.nHeight};
|
const int height{tip.nHeight};
|
||||||
|
@ -1328,7 +1328,7 @@ static RPCHelpMan getdeploymentinfo()
|
||||||
{
|
{
|
||||||
const ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
const ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CChainState& active_chainstate = chainman.ActiveChainstate();
|
const Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
|
|
||||||
const CBlockIndex* blockindex;
|
const CBlockIndex* blockindex;
|
||||||
if (request.params[0].isNull()) {
|
if (request.params[0].isNull()) {
|
||||||
|
@ -2148,7 +2148,7 @@ static RPCHelpMan scantxoutset()
|
||||||
{
|
{
|
||||||
ChainstateManager& chainman = EnsureChainman(node);
|
ChainstateManager& chainman = EnsureChainman(node);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
active_chainstate.ForceFlushStateToDisk();
|
active_chainstate.ForceFlushStateToDisk();
|
||||||
pcursor = CHECK_NONFATAL(active_chainstate.CoinsDB().Cursor());
|
pcursor = CHECK_NONFATAL(active_chainstate.CoinsDB().Cursor());
|
||||||
tip = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
|
tip = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
|
||||||
|
@ -2328,7 +2328,7 @@ static RPCHelpMan dumptxoutset()
|
||||||
|
|
||||||
UniValue CreateUTXOSnapshot(
|
UniValue CreateUTXOSnapshot(
|
||||||
NodeContext& node,
|
NodeContext& node,
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
AutoFile& afile,
|
AutoFile& afile,
|
||||||
const fs::path& path,
|
const fs::path& path,
|
||||||
const fs::path& temppath)
|
const fs::path& temppath)
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern RecursiveMutex cs_main;
|
||||||
|
|
||||||
class CBlock;
|
class CBlock;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
class UniValue;
|
class UniValue;
|
||||||
namespace node {
|
namespace node {
|
||||||
struct NodeContext;
|
struct NodeContext;
|
||||||
|
@ -54,7 +54,7 @@ void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES],
|
||||||
*/
|
*/
|
||||||
UniValue CreateUTXOSnapshot(
|
UniValue CreateUTXOSnapshot(
|
||||||
node::NodeContext& node,
|
node::NodeContext& node,
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
AutoFile& afile,
|
AutoFile& afile,
|
||||||
const fs::path& path,
|
const fs::path& path,
|
||||||
const fs::path& tmppath);
|
const fs::path& tmppath);
|
||||||
|
|
|
@ -168,7 +168,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
ChainstateManager& chainman = EnsureChainman(node);
|
ChainstateManager& chainman = EnsureChainman(node);
|
||||||
CChainState& chainstate = chainman.ActiveChainstate();
|
Chainstate& chainstate = chainman.ActiveChainstate();
|
||||||
const PackageMempoolAcceptResult package_result = [&] {
|
const PackageMempoolAcceptResult package_result = [&] {
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true);
|
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true);
|
||||||
|
@ -810,7 +810,7 @@ static RPCHelpMan submitpackage()
|
||||||
|
|
||||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
CChainState& chainstate = EnsureChainman(node).ActiveChainstate();
|
Chainstate& chainstate = EnsureChainman(node).ActiveChainstate();
|
||||||
const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false));
|
const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false));
|
||||||
|
|
||||||
// First catch any errors.
|
// First catch any errors.
|
||||||
|
|
|
@ -598,7 +598,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
std::string strMode = "template";
|
std::string strMode = "template";
|
||||||
UniValue lpval = NullUniValue;
|
UniValue lpval = NullUniValue;
|
||||||
std::set<std::string> setClientRules;
|
std::set<std::string> setClientRules;
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
CChain& active_chain = active_chainstate.m_chain;
|
CChain& active_chain = active_chainstate.m_chain;
|
||||||
if (!request.params[0].isNull())
|
if (!request.params[0].isNull())
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ using node::GetTransaction;
|
||||||
using node::NodeContext;
|
using node::NodeContext;
|
||||||
using node::PSBTAnalysis;
|
using node::PSBTAnalysis;
|
||||||
|
|
||||||
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, CChainState& active_chainstate)
|
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, Chainstate& active_chainstate)
|
||||||
{
|
{
|
||||||
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
|
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
|
||||||
//
|
//
|
||||||
|
|
|
@ -66,7 +66,7 @@ static RPCHelpMan gettxoutproof()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
|
|
||||||
// Loop through txids and try to find which block they're in. Exit loop once a block is found.
|
// Loop through txids and try to find which block they're in. Exit loop once a block is found.
|
||||||
for (const auto& tx : setTxids) {
|
for (const auto& tx : setTxids) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
||||||
// make sure index is not corrupted and is able to reload.
|
// make sure index is not corrupted and is able to reload.
|
||||||
BOOST_FIXTURE_TEST_CASE(coinstatsindex_unclean_shutdown, TestChain100Setup)
|
BOOST_FIXTURE_TEST_CASE(coinstatsindex_unclean_shutdown, TestChain100Setup)
|
||||||
{
|
{
|
||||||
CChainState& chainstate = Assert(m_node.chainman)->ActiveChainstate();
|
Chainstate& chainstate = Assert(m_node.chainman)->ActiveChainstate();
|
||||||
const CChainParams& params = Params();
|
const CChainParams& params = Params();
|
||||||
{
|
{
|
||||||
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};
|
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
class DummyChainState final : public CChainState
|
class DummyChainState final : public Chainstate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetMempool(CTxMemPool* mempool)
|
void SetMempool(CTxMemPool* mempool)
|
||||||
|
|
|
@ -85,7 +85,7 @@ void SetMempoolConstraints(ArgsManager& args, FuzzedDataProvider& fuzzed_data_pr
|
||||||
ToString(fuzzed_data_provider.ConsumeIntegralInRange<unsigned>(0, 999)));
|
ToString(fuzzed_data_provider.ConsumeIntegralInRange<unsigned>(0, 999)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CChainState& chainstate)
|
void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Chainstate& chainstate)
|
||||||
{
|
{
|
||||||
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
|
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CCh
|
||||||
SyncWithValidationInterfaceQueue();
|
SyncWithValidationInterfaceQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockTime(FuzzedDataProvider& fuzzed_data_provider, const CChainState& chainstate)
|
void MockTime(FuzzedDataProvider& fuzzed_data_provider, const Chainstate& chainstate)
|
||||||
{
|
{
|
||||||
const auto time = ConsumeTime(fuzzed_data_provider,
|
const auto time = ConsumeTime(fuzzed_data_provider,
|
||||||
chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
|
chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
|
||||||
|
|
|
@ -840,7 +840,7 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
||||||
const int64_t time{0};
|
const int64_t time{0};
|
||||||
const CNetMsgMaker msg_maker{PROTOCOL_VERSION};
|
const CNetMsgMaker msg_maker{PROTOCOL_VERSION};
|
||||||
|
|
||||||
// Force CChainState::IsInitialBlockDownload() to return false.
|
// Force Chainstate::IsInitialBlockDownload() to return false.
|
||||||
// Otherwise PushAddress() isn't called by PeerManager::ProcessMessage().
|
// Otherwise PushAddress() isn't called by PeerManager::ProcessMessage().
|
||||||
TestChainState& chainstate =
|
TestChainState& chainstate =
|
||||||
*static_cast<TestChainState*>(&m_node.chainman->ActiveChainstate());
|
*static_cast<TestChainState*>(&m_node.chainman->ActiveChainstate());
|
||||||
|
|
|
@ -296,7 +296,7 @@ void TestChain100Setup::mineBlocks(int num_blocks)
|
||||||
CBlock TestChain100Setup::CreateBlock(
|
CBlock TestChain100Setup::CreateBlock(
|
||||||
const std::vector<CMutableTransaction>& txns,
|
const std::vector<CMutableTransaction>& txns,
|
||||||
const CScript& scriptPubKey,
|
const CScript& scriptPubKey,
|
||||||
CChainState& chainstate)
|
Chainstate& chainstate)
|
||||||
{
|
{
|
||||||
CBlock block = BlockAssembler{chainstate, nullptr}.CreateNewBlock(scriptPubKey)->block;
|
CBlock block = BlockAssembler{chainstate, nullptr}.CreateNewBlock(scriptPubKey)->block;
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ CBlock TestChain100Setup::CreateBlock(
|
||||||
CBlock TestChain100Setup::CreateAndProcessBlock(
|
CBlock TestChain100Setup::CreateAndProcessBlock(
|
||||||
const std::vector<CMutableTransaction>& txns,
|
const std::vector<CMutableTransaction>& txns,
|
||||||
const CScript& scriptPubKey,
|
const CScript& scriptPubKey,
|
||||||
CChainState* chainstate)
|
Chainstate* chainstate)
|
||||||
{
|
{
|
||||||
if (!chainstate) {
|
if (!chainstate) {
|
||||||
chainstate = &Assert(m_node.chainman)->ActiveChainstate();
|
chainstate = &Assert(m_node.chainman)->ActiveChainstate();
|
||||||
|
|
|
@ -134,7 +134,7 @@ struct TestChain100Setup : public TestingSetup {
|
||||||
*/
|
*/
|
||||||
CBlock CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns,
|
CBlock CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns,
|
||||||
const CScript& scriptPubKey,
|
const CScript& scriptPubKey,
|
||||||
CChainState* chainstate = nullptr);
|
Chainstate* chainstate = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new block with just given transactions, coinbase paying to
|
* Create a new block with just given transactions, coinbase paying to
|
||||||
|
@ -143,7 +143,7 @@ struct TestChain100Setup : public TestingSetup {
|
||||||
CBlock CreateBlock(
|
CBlock CreateBlock(
|
||||||
const std::vector<CMutableTransaction>& txns,
|
const std::vector<CMutableTransaction>& txns,
|
||||||
const CScript& scriptPubKey,
|
const CScript& scriptPubKey,
|
||||||
CChainState& chainstate);
|
Chainstate& chainstate);
|
||||||
|
|
||||||
//! Mine a series of new blocks on the active chain.
|
//! Mine a series of new blocks on the active chain.
|
||||||
void mineBlocks(int num_blocks);
|
void mineBlocks(int num_blocks);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
class CValidationInterface;
|
class CValidationInterface;
|
||||||
|
|
||||||
struct TestChainState : public CChainState {
|
struct TestChainState : public Chainstate {
|
||||||
/** Reset the ibd cache to its initial state */
|
/** Reset the ibd cache to its initial state */
|
||||||
void ResetIbd();
|
void ResetIbd();
|
||||||
/** Toggle IsInitialBlockDownload from true to false */
|
/** Toggle IsInitialBlockDownload from true to false */
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, ChainTestingSetup)
|
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, ChainTestingSetup)
|
||||||
|
|
||||||
//! Test resizing coins-related CChainState caches during runtime.
|
//! Test resizing coins-related Chainstate caches during runtime.
|
||||||
//!
|
//!
|
||||||
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||||
return outp;
|
return outp;
|
||||||
};
|
};
|
||||||
|
|
||||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
Chainstate& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
||||||
c1.InitCoinsDB(
|
c1.InitCoinsDB(
|
||||||
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
||||||
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
|
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
|
||||||
|
@ -106,8 +106,8 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 2);
|
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 2);
|
||||||
|
|
||||||
CChainState& background_cs{*[&] {
|
Chainstate& background_cs{*[&] {
|
||||||
for (CChainState* cs : chainman.GetAll()) {
|
for (Chainstate* cs : chainman.GetAll()) {
|
||||||
if (cs != &chainman.ActiveChainstate()) {
|
if (cs != &chainman.ActiveChainstate()) {
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,13 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
|
||||||
ChainstateManager& manager = *m_node.chainman;
|
ChainstateManager& manager = *m_node.chainman;
|
||||||
CTxMemPool& mempool = *m_node.mempool;
|
CTxMemPool& mempool = *m_node.mempool;
|
||||||
|
|
||||||
std::vector<CChainState*> chainstates;
|
std::vector<Chainstate*> chainstates;
|
||||||
|
|
||||||
BOOST_CHECK(!manager.SnapshotBlockhash().has_value());
|
BOOST_CHECK(!manager.SnapshotBlockhash().has_value());
|
||||||
|
|
||||||
// Create a legacy (IBD) chainstate.
|
// Create a legacy (IBD) chainstate.
|
||||||
//
|
//
|
||||||
CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool));
|
Chainstate& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool));
|
||||||
chainstates.push_back(&c1);
|
chainstates.push_back(&c1);
|
||||||
c1.InitCoinsDB(
|
c1.InitCoinsDB(
|
||||||
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
||||||
|
@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
|
||||||
// Create a snapshot-based chainstate.
|
// Create a snapshot-based chainstate.
|
||||||
//
|
//
|
||||||
const uint256 snapshot_blockhash = GetRandHash();
|
const uint256 snapshot_blockhash = GetRandHash();
|
||||||
CChainState& c2 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(
|
Chainstate& c2 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(
|
||||||
&mempool, snapshot_blockhash));
|
&mempool, snapshot_blockhash));
|
||||||
chainstates.push_back(&c2);
|
chainstates.push_back(&c2);
|
||||||
|
|
||||||
|
@ -111,11 +111,11 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
||||||
manager.m_total_coinsdb_cache = max_cache;
|
manager.m_total_coinsdb_cache = max_cache;
|
||||||
manager.m_total_coinstip_cache = max_cache;
|
manager.m_total_coinstip_cache = max_cache;
|
||||||
|
|
||||||
std::vector<CChainState*> chainstates;
|
std::vector<Chainstate*> chainstates;
|
||||||
|
|
||||||
// Create a legacy (IBD) chainstate.
|
// Create a legacy (IBD) chainstate.
|
||||||
//
|
//
|
||||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
Chainstate& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
||||||
chainstates.push_back(&c1);
|
chainstates.push_back(&c1);
|
||||||
c1.InitCoinsDB(
|
c1.InitCoinsDB(
|
||||||
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
||||||
|
@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
||||||
|
|
||||||
// Create a snapshot-based chainstate.
|
// Create a snapshot-based chainstate.
|
||||||
//
|
//
|
||||||
CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
|
Chainstate& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
|
||||||
chainstates.push_back(&c2);
|
chainstates.push_back(&c2);
|
||||||
c2.InitCoinsDB(
|
c2.InitCoinsDB(
|
||||||
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
/*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
|
||||||
|
@ -250,7 +250,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
int chains_tested{0};
|
int chains_tested{0};
|
||||||
|
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
|
BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
|
||||||
CCoinsViewCache& coinscache = chainstate->CoinsTip();
|
CCoinsViewCache& coinscache = chainstate->CoinsTip();
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
||||||
size_t coins_in_background{0};
|
size_t coins_in_background{0};
|
||||||
size_t coins_missing_from_background{0};
|
size_t coins_missing_from_background{0};
|
||||||
|
|
||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (Chainstate* chainstate : chainman.GetAll()) {
|
||||||
BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
|
BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
|
||||||
CCoinsViewCache& coinscache = chainstate->CoinsTip();
|
CCoinsViewCache& coinscache = chainstate->CoinsTip();
|
||||||
bool is_background = chainstate != &chainman.ActiveChainstate();
|
bool is_background = chainstate != &chainman.ActiveChainstate();
|
||||||
|
@ -326,7 +326,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||||
{
|
{
|
||||||
ChainstateManager& chainman = *Assert(m_node.chainman);
|
ChainstateManager& chainman = *Assert(m_node.chainman);
|
||||||
CTxMemPool& mempool = *m_node.mempool;
|
CTxMemPool& mempool = *m_node.mempool;
|
||||||
CChainState& cs1 = chainman.ActiveChainstate();
|
Chainstate& cs1 = chainman.ActiveChainstate();
|
||||||
|
|
||||||
int num_indexes{0};
|
int num_indexes{0};
|
||||||
int num_assumed_valid{0};
|
int num_assumed_valid{0};
|
||||||
|
@ -338,7 +338,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||||
CBlockIndex* assumed_tip{WITH_LOCK(chainman.GetMutex(), return chainman.ActiveChain().Tip())};
|
CBlockIndex* assumed_tip{WITH_LOCK(chainman.GetMutex(), return chainman.ActiveChain().Tip())};
|
||||||
|
|
||||||
auto reload_all_block_indexes = [&]() {
|
auto reload_all_block_indexes = [&]() {
|
||||||
for (CChainState* cs : chainman.GetAll()) {
|
for (Chainstate* cs : chainman.GetAll()) {
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
cs->UnloadBlockIndex();
|
cs->UnloadBlockIndex();
|
||||||
BOOST_CHECK(cs->setBlockIndexCandidates.empty());
|
BOOST_CHECK(cs->setBlockIndexCandidates.empty());
|
||||||
|
@ -373,7 +373,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(expected_assumed_valid, num_assumed_valid);
|
BOOST_CHECK_EQUAL(expected_assumed_valid, num_assumed_valid);
|
||||||
|
|
||||||
CChainState& cs2 = WITH_LOCK(::cs_main,
|
Chainstate& cs2 = WITH_LOCK(::cs_main,
|
||||||
return chainman.InitializeChainstate(&mempool, GetRandHash()));
|
return chainman.InitializeChainstate(&mempool, GetRandHash()));
|
||||||
|
|
||||||
reload_all_block_indexes();
|
reload_all_block_indexes();
|
||||||
|
|
|
@ -13,11 +13,11 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, TestingSetup)
|
||||||
//! Test utilities for detecting when we need to flush the coins cache based
|
//! Test utilities for detecting when we need to flush the coins cache based
|
||||||
//! on estimated memory usage.
|
//! on estimated memory usage.
|
||||||
//!
|
//!
|
||||||
//! @sa CChainState::GetCoinsCacheSizeState()
|
//! @sa Chainstate::GetCoinsCacheSizeState()
|
||||||
//!
|
//!
|
||||||
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
||||||
{
|
{
|
||||||
CChainState& chainstate{m_node.chainman->ActiveChainstate()};
|
Chainstate& chainstate{m_node.chainman->ActiveChainstate()};
|
||||||
|
|
||||||
constexpr bool is_64_bit = sizeof(void*) == 8;
|
constexpr bool is_64_bit = sizeof(void*) == 8;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChain;
|
class CChain;
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
extern RecursiveMutex cs_main;
|
extern RecursiveMutex cs_main;
|
||||||
|
|
||||||
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
|
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
|
||||||
|
|
|
@ -131,7 +131,7 @@ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
|
||||||
uint256 hashAssumeValid;
|
uint256 hashAssumeValid;
|
||||||
arith_uint256 nMinimumChainWork;
|
arith_uint256 nMinimumChainWork;
|
||||||
|
|
||||||
const CBlockIndex* CChainState::FindForkInGlobalIndex(const CBlockLocator& locator) const
|
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ static void LimitMempoolSize(CTxMemPool& pool, CCoinsViewCache& coins_cache)
|
||||||
coins_cache.Uncache(removed);
|
coins_cache.Uncache(removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
static bool IsCurrentForFeeEstimation(Chainstate& active_chainstate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (active_chainstate.IsInitialBlockDownload())
|
if (active_chainstate.IsInitialBlockDownload())
|
||||||
|
@ -286,7 +286,7 @@ static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::MaybeUpdateMempoolForReorg(
|
void Chainstate::MaybeUpdateMempoolForReorg(
|
||||||
DisconnectedBlockTransactions& disconnectpool,
|
DisconnectedBlockTransactions& disconnectpool,
|
||||||
bool fAddToMempool)
|
bool fAddToMempool)
|
||||||
{
|
{
|
||||||
|
@ -424,7 +424,7 @@ namespace {
|
||||||
class MemPoolAccept
|
class MemPoolAccept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MemPoolAccept(CTxMemPool& mempool, CChainState& active_chainstate) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&active_chainstate.CoinsTip(), m_pool), m_active_chainstate(active_chainstate),
|
explicit MemPoolAccept(CTxMemPool& mempool, Chainstate& active_chainstate) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&active_chainstate.CoinsTip(), m_pool), m_active_chainstate(active_chainstate),
|
||||||
m_limit_ancestors(m_pool.m_limits.ancestor_count),
|
m_limit_ancestors(m_pool.m_limits.ancestor_count),
|
||||||
m_limit_ancestor_size(m_pool.m_limits.ancestor_size_vbytes),
|
m_limit_ancestor_size(m_pool.m_limits.ancestor_size_vbytes),
|
||||||
m_limit_descendants(m_pool.m_limits.descendant_count),
|
m_limit_descendants(m_pool.m_limits.descendant_count),
|
||||||
|
@ -658,7 +658,7 @@ private:
|
||||||
CCoinsViewMemPool m_viewmempool;
|
CCoinsViewMemPool m_viewmempool;
|
||||||
CCoinsView m_dummy;
|
CCoinsView m_dummy;
|
||||||
|
|
||||||
CChainState& m_active_chainstate;
|
Chainstate& m_active_chainstate;
|
||||||
|
|
||||||
// The package limits in effect at the time of invocation.
|
// The package limits in effect at the time of invocation.
|
||||||
const size_t m_limit_ancestors;
|
const size_t m_limit_ancestors;
|
||||||
|
@ -1411,7 +1411,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
|
||||||
|
|
||||||
} // anon namespace
|
} // anon namespace
|
||||||
|
|
||||||
MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, const CTransactionRef& tx,
|
MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTransactionRef& tx,
|
||||||
int64_t accept_time, bool bypass_limits, bool test_accept)
|
int64_t accept_time, bool bypass_limits, bool test_accept)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||||
{
|
{
|
||||||
|
@ -1438,7 +1438,7 @@ MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, const CTr
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTxMemPool& pool,
|
PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxMemPool& pool,
|
||||||
const Package& package, bool test_accept)
|
const Package& package, bool test_accept)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
@ -1497,7 +1497,7 @@ void CoinsViews::InitCache()
|
||||||
m_cacheview = std::make_unique<CCoinsViewCache>(&m_catcherview);
|
m_cacheview = std::make_unique<CCoinsViewCache>(&m_catcherview);
|
||||||
}
|
}
|
||||||
|
|
||||||
CChainState::CChainState(
|
Chainstate::Chainstate(
|
||||||
CTxMemPool* mempool,
|
CTxMemPool* mempool,
|
||||||
BlockManager& blockman,
|
BlockManager& blockman,
|
||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
|
@ -1508,7 +1508,7 @@ CChainState::CChainState(
|
||||||
m_chainman(chainman),
|
m_chainman(chainman),
|
||||||
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
|
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
|
||||||
|
|
||||||
void CChainState::InitCoinsDB(
|
void Chainstate::InitCoinsDB(
|
||||||
size_t cache_size_bytes,
|
size_t cache_size_bytes,
|
||||||
bool in_memory,
|
bool in_memory,
|
||||||
bool should_wipe,
|
bool should_wipe,
|
||||||
|
@ -1522,7 +1522,7 @@ void CChainState::InitCoinsDB(
|
||||||
leveldb_name, cache_size_bytes, in_memory, should_wipe);
|
leveldb_name, cache_size_bytes, in_memory, should_wipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::InitCoinsCache(size_t cache_size_bytes)
|
void Chainstate::InitCoinsCache(size_t cache_size_bytes)
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
assert(m_coins_views != nullptr);
|
assert(m_coins_views != nullptr);
|
||||||
|
@ -1532,10 +1532,10 @@ void CChainState::InitCoinsCache(size_t cache_size_bytes)
|
||||||
|
|
||||||
// Note that though this is marked const, we may end up modifying `m_cached_finished_ibd`, which
|
// Note that though this is marked const, we may end up modifying `m_cached_finished_ibd`, which
|
||||||
// is a performance-related implementation detail. This function must be marked
|
// is a performance-related implementation detail. This function must be marked
|
||||||
// `const` so that `CValidationInterface` clients (which are given a `const CChainState*`)
|
// `const` so that `CValidationInterface` clients (which are given a `const Chainstate*`)
|
||||||
// can call it.
|
// can call it.
|
||||||
//
|
//
|
||||||
bool CChainState::IsInitialBlockDownload() const
|
bool Chainstate::IsInitialBlockDownload() const
|
||||||
{
|
{
|
||||||
// Optimization: pre-test latch before taking the lock.
|
// Optimization: pre-test latch before taking the lock.
|
||||||
if (m_cached_finished_ibd.load(std::memory_order_relaxed))
|
if (m_cached_finished_ibd.load(std::memory_order_relaxed))
|
||||||
|
@ -1577,7 +1577,7 @@ static void AlertNotify(const std::string& strMessage)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::CheckForkWarningConditions()
|
void Chainstate::CheckForkWarningConditions()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
|
@ -1596,7 +1596,7 @@ void CChainState::CheckForkWarningConditions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called both upon regular invalid block discovery *and* InvalidateBlock
|
// Called both upon regular invalid block discovery *and* InvalidateBlock
|
||||||
void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
|
void Chainstate::InvalidChainFound(CBlockIndex* pindexNew)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (!m_chainman.m_best_invalid || pindexNew->nChainWork > m_chainman.m_best_invalid->nChainWork) {
|
if (!m_chainman.m_best_invalid || pindexNew->nChainWork > m_chainman.m_best_invalid->nChainWork) {
|
||||||
|
@ -1619,7 +1619,7 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
|
||||||
|
|
||||||
// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
|
// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
|
||||||
// which does its own setBlockIndexCandidates management.
|
// which does its own setBlockIndexCandidates management.
|
||||||
void CChainState::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
|
void Chainstate::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
|
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
|
||||||
|
@ -1824,7 +1824,7 @@ int ApplyTxInUndo(Coin&& undo, CCoinsViewCache& view, const COutPoint& out)
|
||||||
|
|
||||||
/** Undo the effects of this block (with given index) on the UTXO set represented by coins.
|
/** Undo the effects of this block (with given index) on the UTXO set represented by coins.
|
||||||
* When FAILED is returned, view is left in an indeterminate state. */
|
* When FAILED is returned, view is left in an indeterminate state. */
|
||||||
DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view)
|
DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view)
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
bool fClean = true;
|
bool fClean = true;
|
||||||
|
@ -1977,7 +1977,7 @@ static int64_t nBlocksTotal = 0;
|
||||||
/** Apply the effects of this block (with given index) on the UTXO set represented by coins.
|
/** Apply the effects of this block (with given index) on the UTXO set represented by coins.
|
||||||
* Validity checks that depend on the UTXO set are also done; ConnectBlock()
|
* Validity checks that depend on the UTXO set are also done; ConnectBlock()
|
||||||
* can fail if those validity checks fail (among other reasons). */
|
* can fail if those validity checks fail (among other reasons). */
|
||||||
bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
|
bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state, CBlockIndex* pindex,
|
||||||
CCoinsViewCache& view, bool fJustCheck)
|
CCoinsViewCache& view, bool fJustCheck)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
@ -2289,7 +2289,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoinsCacheSizeState CChainState::GetCoinsCacheSizeState()
|
CoinsCacheSizeState Chainstate::GetCoinsCacheSizeState()
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
return this->GetCoinsCacheSizeState(
|
return this->GetCoinsCacheSizeState(
|
||||||
|
@ -2297,7 +2297,7 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState()
|
||||||
m_mempool ? m_mempool->m_max_size_bytes : 0);
|
m_mempool ? m_mempool->m_max_size_bytes : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
|
CoinsCacheSizeState Chainstate::GetCoinsCacheSizeState(
|
||||||
size_t max_coins_cache_size_bytes,
|
size_t max_coins_cache_size_bytes,
|
||||||
size_t max_mempool_size_bytes)
|
size_t max_mempool_size_bytes)
|
||||||
{
|
{
|
||||||
|
@ -2321,7 +2321,7 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
|
||||||
return CoinsCacheSizeState::OK;
|
return CoinsCacheSizeState::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::FlushStateToDisk(
|
bool Chainstate::FlushStateToDisk(
|
||||||
BlockValidationState &state,
|
BlockValidationState &state,
|
||||||
FlushStateMode mode,
|
FlushStateMode mode,
|
||||||
int nManualPruneHeight)
|
int nManualPruneHeight)
|
||||||
|
@ -2464,7 +2464,7 @@ bool CChainState::FlushStateToDisk(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::ForceFlushStateToDisk()
|
void Chainstate::ForceFlushStateToDisk()
|
||||||
{
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!this->FlushStateToDisk(state, FlushStateMode::ALWAYS)) {
|
if (!this->FlushStateToDisk(state, FlushStateMode::ALWAYS)) {
|
||||||
|
@ -2472,7 +2472,7 @@ void CChainState::ForceFlushStateToDisk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::PruneAndFlush()
|
void Chainstate::PruneAndFlush()
|
||||||
{
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
m_blockman.m_check_for_pruning = true;
|
m_blockman.m_check_for_pruning = true;
|
||||||
|
@ -2519,7 +2519,7 @@ static void UpdateTipLog(
|
||||||
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages) : "");
|
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::UpdateTip(const CBlockIndex* pindexNew)
|
void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
const auto& coins_tip = this->CoinsTip();
|
const auto& coins_tip = this->CoinsTip();
|
||||||
|
@ -2575,7 +2575,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
|
||||||
* disconnectpool (note that the caller is responsible for mempool consistency
|
* disconnectpool (note that the caller is responsible for mempool consistency
|
||||||
* in any case).
|
* in any case).
|
||||||
*/
|
*/
|
||||||
bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTransactions* disconnectpool)
|
bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTransactions* disconnectpool)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
||||||
|
@ -2691,7 +2691,7 @@ public:
|
||||||
*
|
*
|
||||||
* The block is added to connectTrace if connection succeeds.
|
* The block is added to connectTrace if connection succeeds.
|
||||||
*/
|
*/
|
||||||
bool CChainState::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool)
|
bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
||||||
|
@ -2759,7 +2759,7 @@ bool CChainState::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew
|
||||||
* Return the tip of the chain with the most work in it, that isn't
|
* Return the tip of the chain with the most work in it, that isn't
|
||||||
* known to be invalid (it's however far from certain to be valid).
|
* known to be invalid (it's however far from certain to be valid).
|
||||||
*/
|
*/
|
||||||
CBlockIndex* CChainState::FindMostWorkChain()
|
CBlockIndex* Chainstate::FindMostWorkChain()
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
do {
|
do {
|
||||||
|
@ -2818,7 +2818,7 @@ CBlockIndex* CChainState::FindMostWorkChain()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete all entries in setBlockIndexCandidates that are worse than the current tip. */
|
/** Delete all entries in setBlockIndexCandidates that are worse than the current tip. */
|
||||||
void CChainState::PruneBlockIndexCandidates() {
|
void Chainstate::PruneBlockIndexCandidates() {
|
||||||
// Note that we can't delete the current block itself, as we may need to return to it later in case a
|
// Note that we can't delete the current block itself, as we may need to return to it later in case a
|
||||||
// reorganization to a better block fails.
|
// reorganization to a better block fails.
|
||||||
std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexCandidates.begin();
|
std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexCandidates.begin();
|
||||||
|
@ -2835,7 +2835,7 @@ void CChainState::PruneBlockIndexCandidates() {
|
||||||
*
|
*
|
||||||
* @returns true unless a system error occurred
|
* @returns true unless a system error occurred
|
||||||
*/
|
*/
|
||||||
bool CChainState::ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace)
|
bool Chainstate::ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
if (m_mempool) AssertLockHeld(m_mempool->cs);
|
||||||
|
@ -2927,7 +2927,7 @@ static SynchronizationState GetSynchronizationState(bool init)
|
||||||
return SynchronizationState::INIT_DOWNLOAD;
|
return SynchronizationState::INIT_DOWNLOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NotifyHeaderTip(CChainState& chainstate) LOCKS_EXCLUDED(cs_main) {
|
static bool NotifyHeaderTip(Chainstate& chainstate) LOCKS_EXCLUDED(cs_main) {
|
||||||
bool fNotify = false;
|
bool fNotify = false;
|
||||||
bool fInitialBlockDownload = false;
|
bool fInitialBlockDownload = false;
|
||||||
static CBlockIndex* pindexHeaderOld = nullptr;
|
static CBlockIndex* pindexHeaderOld = nullptr;
|
||||||
|
@ -2957,7 +2957,7 @@ static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::ActivateBestChain(BlockValidationState& state, std::shared_ptr<const CBlock> pblock)
|
bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<const CBlock> pblock)
|
||||||
{
|
{
|
||||||
AssertLockNotHeld(m_chainstate_mutex);
|
AssertLockNotHeld(m_chainstate_mutex);
|
||||||
|
|
||||||
|
@ -3059,7 +3059,7 @@ bool CChainState::ActivateBestChain(BlockValidationState& state, std::shared_ptr
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
|
bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
AssertLockNotHeld(m_chainstate_mutex);
|
AssertLockNotHeld(m_chainstate_mutex);
|
||||||
AssertLockNotHeld(::cs_main);
|
AssertLockNotHeld(::cs_main);
|
||||||
|
@ -3090,7 +3090,7 @@ bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex
|
||||||
return ActivateBestChain(state, std::shared_ptr<const CBlock>());
|
return ActivateBestChain(state, std::shared_ptr<const CBlock>());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex)
|
bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
AssertLockNotHeld(m_chainstate_mutex);
|
AssertLockNotHeld(m_chainstate_mutex);
|
||||||
AssertLockNotHeld(::cs_main);
|
AssertLockNotHeld(::cs_main);
|
||||||
|
@ -3233,7 +3233,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pind
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
void Chainstate::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
int nHeight = pindex->nHeight;
|
int nHeight = pindex->nHeight;
|
||||||
|
@ -3266,7 +3266,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
|
/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
|
||||||
void CChainState::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos)
|
void Chainstate::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
pindexNew->nTx = block.vtx.size();
|
pindexNew->nTx = block.vtx.size();
|
||||||
|
@ -3737,7 +3737,7 @@ void ChainstateManager::ReportHeadersPresync(const arith_uint256& work, int64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
|
/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
|
||||||
bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock, bool min_pow_checked)
|
bool Chainstate::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, BlockValidationState& state, CBlockIndex** ppindex, bool fRequested, const FlatFilePos* dbp, bool* fNewBlock, bool min_pow_checked)
|
||||||
{
|
{
|
||||||
const CBlock& block = *pblock;
|
const CBlock& block = *pblock;
|
||||||
|
|
||||||
|
@ -3862,7 +3862,7 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
|
||||||
MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef& tx, bool test_accept)
|
MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef& tx, bool test_accept)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
CChainState& active_chainstate = ActiveChainstate();
|
Chainstate& active_chainstate = ActiveChainstate();
|
||||||
if (!active_chainstate.GetMempool()) {
|
if (!active_chainstate.GetMempool()) {
|
||||||
TxValidationState state;
|
TxValidationState state;
|
||||||
state.Invalid(TxValidationResult::TX_NO_MEMPOOL, "no-mempool");
|
state.Invalid(TxValidationResult::TX_NO_MEMPOOL, "no-mempool");
|
||||||
|
@ -3875,7 +3875,7 @@ MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef&
|
||||||
|
|
||||||
bool TestBlockValidity(BlockValidationState& state,
|
bool TestBlockValidity(BlockValidationState& state,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
const CBlock& block,
|
const CBlock& block,
|
||||||
CBlockIndex* pindexPrev,
|
CBlockIndex* pindexPrev,
|
||||||
const std::function<NodeClock::time_point()>& adjusted_time_callback,
|
const std::function<NodeClock::time_point()>& adjusted_time_callback,
|
||||||
|
@ -3907,7 +3907,7 @@ bool TestBlockValidity(BlockValidationState& state,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called from the RPC code for pruneblockchain */
|
/* This function is called from the RPC code for pruneblockchain */
|
||||||
void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight)
|
void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight)
|
||||||
{
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!active_chainstate.FlushStateToDisk(
|
if (!active_chainstate.FlushStateToDisk(
|
||||||
|
@ -3916,14 +3916,14 @@ void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeigh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::LoadMempool(const fs::path& load_path, FopenFn mockable_fopen_function)
|
void Chainstate::LoadMempool(const fs::path& load_path, FopenFn mockable_fopen_function)
|
||||||
{
|
{
|
||||||
if (!m_mempool) return;
|
if (!m_mempool) return;
|
||||||
::LoadMempool(*m_mempool, load_path, *this, mockable_fopen_function);
|
::LoadMempool(*m_mempool, load_path, *this, mockable_fopen_function);
|
||||||
m_mempool->SetLoadTried(!ShutdownRequested());
|
m_mempool->SetLoadTried(!ShutdownRequested());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::LoadChainTip()
|
bool Chainstate::LoadChainTip()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
const CCoinsViewCache& coins_cache = CoinsTip();
|
const CCoinsViewCache& coins_cache = CoinsTip();
|
||||||
|
@ -3962,7 +3962,7 @@ CVerifyDB::~CVerifyDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVerifyDB::VerifyDB(
|
bool CVerifyDB::VerifyDB(
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
const Consensus::Params& consensus_params,
|
const Consensus::Params& consensus_params,
|
||||||
CCoinsView& coinsview,
|
CCoinsView& coinsview,
|
||||||
int nCheckLevel, int nCheckDepth)
|
int nCheckLevel, int nCheckDepth)
|
||||||
|
@ -4078,7 +4078,7 @@ bool CVerifyDB::VerifyDB(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. */
|
/** Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. */
|
||||||
bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs)
|
bool Chainstate::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
// TODO: merge with ConnectBlock
|
// TODO: merge with ConnectBlock
|
||||||
|
@ -4099,7 +4099,7 @@ bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& i
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::ReplayBlocks()
|
bool Chainstate::ReplayBlocks()
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
@ -4167,7 +4167,7 @@ bool CChainState::ReplayBlocks()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::NeedsRedownload() const
|
bool Chainstate::NeedsRedownload() const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
|
@ -4185,7 +4185,7 @@ bool CChainState::NeedsRedownload() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::UnloadBlockIndex()
|
void Chainstate::UnloadBlockIndex()
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
nBlockSequenceId = 1;
|
nBlockSequenceId = 1;
|
||||||
|
@ -4254,7 +4254,7 @@ bool ChainstateManager::LoadBlockIndex()
|
||||||
// detecting "holistically" whether the block index under consideration
|
// detecting "holistically" whether the block index under consideration
|
||||||
// relied on an assumed-valid ancestor, but this proved to be too slow to
|
// relied on an assumed-valid ancestor, but this proved to be too slow to
|
||||||
// be practical.
|
// be practical.
|
||||||
for (CChainState* chainstate : GetAll()) {
|
for (Chainstate* chainstate : GetAll()) {
|
||||||
if (chainstate->reliesOnAssumedValid() ||
|
if (chainstate->reliesOnAssumedValid() ||
|
||||||
pindex->nHeight < first_assumed_valid_height) {
|
pindex->nHeight < first_assumed_valid_height) {
|
||||||
chainstate->setBlockIndexCandidates.insert(pindex);
|
chainstate->setBlockIndexCandidates.insert(pindex);
|
||||||
|
@ -4283,7 +4283,7 @@ bool ChainstateManager::LoadBlockIndex()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::LoadGenesisBlock()
|
bool Chainstate::LoadGenesisBlock()
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
@ -4309,7 +4309,7 @@ bool CChainState::LoadGenesisBlock()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::LoadExternalBlockFile(
|
void Chainstate::LoadExternalBlockFile(
|
||||||
FILE* fileIn,
|
FILE* fileIn,
|
||||||
FlatFilePos* dbp,
|
FlatFilePos* dbp,
|
||||||
std::multimap<uint256, FlatFilePos>* blocks_with_unknown_parent)
|
std::multimap<uint256, FlatFilePos>* blocks_with_unknown_parent)
|
||||||
|
@ -4436,7 +4436,7 @@ void CChainState::LoadExternalBlockFile(
|
||||||
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
|
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::CheckBlockIndex()
|
void Chainstate::CheckBlockIndex()
|
||||||
{
|
{
|
||||||
if (!fCheckBlockIndex) {
|
if (!fCheckBlockIndex) {
|
||||||
return;
|
return;
|
||||||
|
@ -4658,7 +4658,7 @@ void CChainState::CheckBlockIndex()
|
||||||
assert(nNodes == forward.size());
|
assert(nNodes == forward.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CChainState::ToString()
|
std::string Chainstate::ToString()
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
CBlockIndex* tip = m_chain.Tip();
|
CBlockIndex* tip = m_chain.Tip();
|
||||||
|
@ -4667,7 +4667,7 @@ std::string CChainState::ToString()
|
||||||
tip ? tip->nHeight : -1, tip ? tip->GetBlockHash().ToString() : "null");
|
tip ? tip->nHeight : -1, tip ? tip->GetBlockHash().ToString() : "null");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChainState::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
|
bool Chainstate::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
if (coinstip_size == m_coinstip_cache_size_bytes &&
|
if (coinstip_size == m_coinstip_cache_size_bytes &&
|
||||||
|
@ -4728,10 +4728,10 @@ std::optional<uint256> ChainstateManager::SnapshotBlockhash() const
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CChainState*> ChainstateManager::GetAll()
|
std::vector<Chainstate*> ChainstateManager::GetAll()
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
std::vector<CChainState*> out;
|
std::vector<Chainstate*> out;
|
||||||
|
|
||||||
if (!IsSnapshotValidated() && m_ibd_chainstate) {
|
if (!IsSnapshotValidated() && m_ibd_chainstate) {
|
||||||
out.push_back(m_ibd_chainstate.get());
|
out.push_back(m_ibd_chainstate.get());
|
||||||
|
@ -4744,18 +4744,18 @@ std::vector<CChainState*> ChainstateManager::GetAll()
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
CChainState& ChainstateManager::InitializeChainstate(
|
Chainstate& ChainstateManager::InitializeChainstate(
|
||||||
CTxMemPool* mempool, const std::optional<uint256>& snapshot_blockhash)
|
CTxMemPool* mempool, const std::optional<uint256>& snapshot_blockhash)
|
||||||
{
|
{
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
bool is_snapshot = snapshot_blockhash.has_value();
|
bool is_snapshot = snapshot_blockhash.has_value();
|
||||||
std::unique_ptr<CChainState>& to_modify =
|
std::unique_ptr<Chainstate>& to_modify =
|
||||||
is_snapshot ? m_snapshot_chainstate : m_ibd_chainstate;
|
is_snapshot ? m_snapshot_chainstate : m_ibd_chainstate;
|
||||||
|
|
||||||
if (to_modify) {
|
if (to_modify) {
|
||||||
throw std::logic_error("should not be overwriting a chainstate");
|
throw std::logic_error("should not be overwriting a chainstate");
|
||||||
}
|
}
|
||||||
to_modify.reset(new CChainState(mempool, m_blockman, *this, snapshot_blockhash));
|
to_modify.reset(new Chainstate(mempool, m_blockman, *this, snapshot_blockhash));
|
||||||
|
|
||||||
// Snapshot chainstates and initial IBD chaintates always become active.
|
// Snapshot chainstates and initial IBD chaintates always become active.
|
||||||
if (is_snapshot || (!is_snapshot && !m_active_chainstate)) {
|
if (is_snapshot || (!is_snapshot && !m_active_chainstate)) {
|
||||||
|
@ -4825,7 +4825,7 @@ bool ChainstateManager::ActivateSnapshot(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto snapshot_chainstate = WITH_LOCK(::cs_main,
|
auto snapshot_chainstate = WITH_LOCK(::cs_main,
|
||||||
return std::make_unique<CChainState>(
|
return std::make_unique<Chainstate>(
|
||||||
/*mempool=*/nullptr, m_blockman, *this, base_blockhash));
|
/*mempool=*/nullptr, m_blockman, *this, base_blockhash));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4875,7 +4875,7 @@ static void FlushSnapshotToDisk(CCoinsViewCache& coins_cache, bool snapshot_load
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChainstateManager::PopulateAndValidateSnapshot(
|
bool ChainstateManager::PopulateAndValidateSnapshot(
|
||||||
CChainState& snapshot_chainstate,
|
Chainstate& snapshot_chainstate,
|
||||||
AutoFile& coins_file,
|
AutoFile& coins_file,
|
||||||
const SnapshotMetadata& metadata)
|
const SnapshotMetadata& metadata)
|
||||||
{
|
{
|
||||||
|
@ -4969,7 +4969,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
||||||
|
|
||||||
// Important that we set this. This and the coins_cache accesses above are
|
// Important that we set this. This and the coins_cache accesses above are
|
||||||
// sort of a layer violation, but either we reach into the innards of
|
// sort of a layer violation, but either we reach into the innards of
|
||||||
// CCoinsViewCache here or we have to invert some of the CChainState to
|
// CCoinsViewCache here or we have to invert some of the Chainstate to
|
||||||
// embed them in a snapshot-activation-specific CCoinsViewCache bulk load
|
// embed them in a snapshot-activation-specific CCoinsViewCache bulk load
|
||||||
// method.
|
// method.
|
||||||
coins_cache.SetBestBlock(base_blockhash);
|
coins_cache.SetBestBlock(base_blockhash);
|
||||||
|
@ -5048,7 +5048,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
||||||
index->nStatus |= BLOCK_ASSUMED_VALID;
|
index->nStatus |= BLOCK_ASSUMED_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fake BLOCK_OPT_WITNESS so that CChainState::NeedsRedownload()
|
// Fake BLOCK_OPT_WITNESS so that Chainstate::NeedsRedownload()
|
||||||
// won't ask to rewind the entire assumed-valid chain on startup.
|
// won't ask to rewind the entire assumed-valid chain on startup.
|
||||||
if (DeploymentActiveAt(*index, *this, Consensus::DEPLOYMENT_SEGWIT)) {
|
if (DeploymentActiveAt(*index, *this, Consensus::DEPLOYMENT_SEGWIT)) {
|
||||||
index->nStatus |= BLOCK_OPT_WITNESS;
|
index->nStatus |= BLOCK_OPT_WITNESS;
|
||||||
|
@ -5071,7 +5071,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CChainState& ChainstateManager::ActiveChainstate() const
|
Chainstate& ChainstateManager::ActiveChainstate() const
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
assert(m_active_chainstate);
|
assert(m_active_chainstate);
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CChainState;
|
class Chainstate;
|
||||||
class CBlockTreeDB;
|
class CBlockTreeDB;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
|
@ -127,7 +127,7 @@ bool AbortNode(BlockValidationState& state, const std::string& strMessage, const
|
||||||
double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
|
double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
|
||||||
|
|
||||||
/** Prune block files up to a given height */
|
/** Prune block files up to a given height */
|
||||||
void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight);
|
void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation result for a single transaction mempool acceptance.
|
* Validation result for a single transaction mempool acceptance.
|
||||||
|
@ -240,7 +240,7 @@ struct PackageMempoolAcceptResult
|
||||||
*
|
*
|
||||||
* @returns a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.
|
* @returns a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.
|
||||||
*/
|
*/
|
||||||
MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, const CTransactionRef& tx,
|
MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTransactionRef& tx,
|
||||||
int64_t accept_time, bool bypass_limits, bool test_accept)
|
int64_t accept_time, bool bypass_limits, bool test_accept)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, const CTr
|
||||||
* If a transaction fails, validation will exit early and some results may be missing. It is also
|
* If a transaction fails, validation will exit early and some results may be missing. It is also
|
||||||
* possible for the package to be partially submitted.
|
* possible for the package to be partially submitted.
|
||||||
*/
|
*/
|
||||||
PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTxMemPool& pool,
|
PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxMemPool& pool,
|
||||||
const Package& txns, bool test_accept)
|
const Package& txns, bool test_accept)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
|
||||||
/** Check a block is completely valid from start to finish (only works on top of our current best block) */
|
/** Check a block is completely valid from start to finish (only works on top of our current best block) */
|
||||||
bool TestBlockValidity(BlockValidationState& state,
|
bool TestBlockValidity(BlockValidationState& state,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
const CBlock& block,
|
const CBlock& block,
|
||||||
CBlockIndex* pindexPrev,
|
CBlockIndex* pindexPrev,
|
||||||
const std::function<NodeClock::time_point()>& adjusted_time_callback,
|
const std::function<NodeClock::time_point()>& adjusted_time_callback,
|
||||||
|
@ -352,7 +352,7 @@ public:
|
||||||
CVerifyDB();
|
CVerifyDB();
|
||||||
~CVerifyDB();
|
~CVerifyDB();
|
||||||
bool VerifyDB(
|
bool VerifyDB(
|
||||||
CChainState& chainstate,
|
Chainstate& chainstate,
|
||||||
const Consensus::Params& consensus_params,
|
const Consensus::Params& consensus_params,
|
||||||
CCoinsView& coinsview,
|
CCoinsView& coinsview,
|
||||||
int nCheckLevel,
|
int nCheckLevel,
|
||||||
|
@ -368,7 +368,7 @@ enum DisconnectResult
|
||||||
|
|
||||||
class ConnectTrace;
|
class ConnectTrace;
|
||||||
|
|
||||||
/** @see CChainState::FlushStateToDisk */
|
/** @see Chainstate::FlushStateToDisk */
|
||||||
enum class FlushStateMode {
|
enum class FlushStateMode {
|
||||||
NONE,
|
NONE,
|
||||||
IF_NEEDED,
|
IF_NEEDED,
|
||||||
|
@ -421,7 +421,7 @@ enum class CoinsCacheSizeState
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CChainState stores and provides an API to update our local knowledge of the
|
* Chainstate stores and provides an API to update our local knowledge of the
|
||||||
* current best chain.
|
* current best chain.
|
||||||
*
|
*
|
||||||
* Eventually, the API here is targeted at being exposed externally as a
|
* Eventually, the API here is targeted at being exposed externally as a
|
||||||
|
@ -434,7 +434,7 @@ enum class CoinsCacheSizeState
|
||||||
* whereas block information and metadata independent of the current tip is
|
* whereas block information and metadata independent of the current tip is
|
||||||
* kept in `BlockManager`.
|
* kept in `BlockManager`.
|
||||||
*/
|
*/
|
||||||
class CChainState
|
class Chainstate
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +472,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Reference to a BlockManager instance which itself is shared across all
|
//! Reference to a BlockManager instance which itself is shared across all
|
||||||
//! CChainState instances.
|
//! Chainstate instances.
|
||||||
node::BlockManager& m_blockman;
|
node::BlockManager& m_blockman;
|
||||||
|
|
||||||
/** Chain parameters for this chainstate */
|
/** Chain parameters for this chainstate */
|
||||||
|
@ -484,7 +484,7 @@ public:
|
||||||
//! chainstate within deeply nested method calls.
|
//! chainstate within deeply nested method calls.
|
||||||
ChainstateManager& m_chainman;
|
ChainstateManager& m_chainman;
|
||||||
|
|
||||||
explicit CChainState(
|
explicit Chainstate(
|
||||||
CTxMemPool* mempool,
|
CTxMemPool* mempool,
|
||||||
node::BlockManager& blockman,
|
node::BlockManager& blockman,
|
||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
|
@ -814,7 +814,7 @@ private:
|
||||||
//! This is especially important when, e.g., calling ActivateBestChain()
|
//! This is especially important when, e.g., calling ActivateBestChain()
|
||||||
//! on all chainstates because we are not able to hold ::cs_main going into
|
//! on all chainstates because we are not able to hold ::cs_main going into
|
||||||
//! that call.
|
//! that call.
|
||||||
std::unique_ptr<CChainState> m_ibd_chainstate GUARDED_BY(::cs_main);
|
std::unique_ptr<Chainstate> m_ibd_chainstate GUARDED_BY(::cs_main);
|
||||||
|
|
||||||
//! A chainstate initialized on the basis of a UTXO snapshot. If this is
|
//! A chainstate initialized on the basis of a UTXO snapshot. If this is
|
||||||
//! non-null, it is always our active chainstate.
|
//! non-null, it is always our active chainstate.
|
||||||
|
@ -825,7 +825,7 @@ private:
|
||||||
//! This is especially important when, e.g., calling ActivateBestChain()
|
//! This is especially important when, e.g., calling ActivateBestChain()
|
||||||
//! on all chainstates because we are not able to hold ::cs_main going into
|
//! on all chainstates because we are not able to hold ::cs_main going into
|
||||||
//! that call.
|
//! that call.
|
||||||
std::unique_ptr<CChainState> m_snapshot_chainstate GUARDED_BY(::cs_main);
|
std::unique_ptr<Chainstate> m_snapshot_chainstate GUARDED_BY(::cs_main);
|
||||||
|
|
||||||
//! Points to either the ibd or snapshot chainstate; indicates our
|
//! Points to either the ibd or snapshot chainstate; indicates our
|
||||||
//! most-work chain.
|
//! most-work chain.
|
||||||
|
@ -836,7 +836,7 @@ private:
|
||||||
//! This is especially important when, e.g., calling ActivateBestChain()
|
//! This is especially important when, e.g., calling ActivateBestChain()
|
||||||
//! on all chainstates because we are not able to hold ::cs_main going into
|
//! on all chainstates because we are not able to hold ::cs_main going into
|
||||||
//! that call.
|
//! that call.
|
||||||
CChainState* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
|
Chainstate* m_active_chainstate GUARDED_BY(::cs_main) {nullptr};
|
||||||
|
|
||||||
//! If true, the assumed-valid chainstate has been fully validated
|
//! If true, the assumed-valid chainstate has been fully validated
|
||||||
//! by the background validation chainstate.
|
//! by the background validation chainstate.
|
||||||
|
@ -846,7 +846,7 @@ private:
|
||||||
|
|
||||||
//! Internal helper for ActivateSnapshot().
|
//! Internal helper for ActivateSnapshot().
|
||||||
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
||||||
CChainState& snapshot_chainstate,
|
Chainstate& snapshot_chainstate,
|
||||||
AutoFile& coins_file,
|
AutoFile& coins_file,
|
||||||
const node::SnapshotMetadata& metadata);
|
const node::SnapshotMetadata& metadata);
|
||||||
|
|
||||||
|
@ -862,7 +862,7 @@ private:
|
||||||
BlockValidationState& state,
|
BlockValidationState& state,
|
||||||
CBlockIndex** ppindex,
|
CBlockIndex** ppindex,
|
||||||
bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
friend CChainState;
|
friend Chainstate;
|
||||||
|
|
||||||
/** Most recent headers presync progress update, for rate-limiting. */
|
/** Most recent headers presync progress update, for rate-limiting. */
|
||||||
std::chrono::time_point<std::chrono::steady_clock> m_last_presync_update GUARDED_BY(::cs_main) {};
|
std::chrono::time_point<std::chrono::steady_clock> m_last_presync_update GUARDED_BY(::cs_main) {};
|
||||||
|
@ -936,19 +936,19 @@ public:
|
||||||
// constructor
|
// constructor
|
||||||
//! @param[in] snapshot_blockhash If given, signify that this chainstate
|
//! @param[in] snapshot_blockhash If given, signify that this chainstate
|
||||||
//! is based on a snapshot.
|
//! is based on a snapshot.
|
||||||
CChainState& InitializeChainstate(
|
Chainstate& InitializeChainstate(
|
||||||
CTxMemPool* mempool,
|
CTxMemPool* mempool,
|
||||||
const std::optional<uint256>& snapshot_blockhash = std::nullopt)
|
const std::optional<uint256>& snapshot_blockhash = std::nullopt)
|
||||||
LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||||
|
|
||||||
//! Get all chainstates currently being used.
|
//! Get all chainstates currently being used.
|
||||||
std::vector<CChainState*> GetAll();
|
std::vector<Chainstate*> GetAll();
|
||||||
|
|
||||||
//! Construct and activate a Chainstate on the basis of UTXO snapshot data.
|
//! Construct and activate a Chainstate on the basis of UTXO snapshot data.
|
||||||
//!
|
//!
|
||||||
//! Steps:
|
//! Steps:
|
||||||
//!
|
//!
|
||||||
//! - Initialize an unused CChainState.
|
//! - Initialize an unused Chainstate.
|
||||||
//! - Load its `CoinsViews` contents from `coins_file`.
|
//! - Load its `CoinsViews` contents from `coins_file`.
|
||||||
//! - Verify that the hash of the resulting coinsdb matches the expected hash
|
//! - Verify that the hash of the resulting coinsdb matches the expected hash
|
||||||
//! per assumeutxo chain parameters.
|
//! per assumeutxo chain parameters.
|
||||||
|
@ -961,7 +961,7 @@ public:
|
||||||
AutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory);
|
AutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory);
|
||||||
|
|
||||||
//! The most-work chain.
|
//! The most-work chain.
|
||||||
CChainState& ActiveChainstate() const;
|
Chainstate& ActiveChainstate() const;
|
||||||
CChain& ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChainstate().m_chain; }
|
CChain& ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChainstate().m_chain; }
|
||||||
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Height(); }
|
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Height(); }
|
||||||
CBlockIndex* ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Tip(); }
|
CBlockIndex* ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex()) { return ActiveChain().Tip(); }
|
||||||
|
|
|
@ -13,7 +13,7 @@ race:zmq::*
|
||||||
race:bitcoin-qt
|
race:bitcoin-qt
|
||||||
|
|
||||||
# deadlock (TODO fix)
|
# deadlock (TODO fix)
|
||||||
deadlock:CChainState::ConnectTip
|
deadlock:Chainstate::ConnectTip
|
||||||
|
|
||||||
# Intentional deadlock in tests
|
# Intentional deadlock in tests
|
||||||
deadlock:sync_tests::potential_deadlock_detected
|
deadlock:sync_tests::potential_deadlock_detected
|
||||||
|
|
Loading…
Add table
Reference in a new issue