7#include <chainparams.h>
47 CBlockIndex* genesis = chainman.ActiveChainstate().m_chain[0];
49 std::vector<CBlockIndex*>
blocks;
81 chainman.InvalidBlockFound(index, state);
85 block.
vtx = std::vector<CTransactionRef>(nTx);
87 chainman.ReceivedBlockTransactions(block, index, pos);
96 auto& chain = chainman.ActiveChain();
116 chain.SetTip(*chain[
fork->nHeight]);
133 chainman.InvalidBlockFound(block, state);
135 chainman.InvalidChainFound(
to_connect.front());
142 chain.SetTip(*block);
143 chainman.ActiveChainstate().PruneBlockIndexCandidates();
158 auto& chain = chainman.ActiveChain();
170 std::multimap<CBlockIndex*, CBlockIndex*>::iterator
_it =
range.first;
188 block.
vtx = std::vector<CTransactionRef>(index->nTx);
190 chainman.ReceivedBlockTransactions(block, index, pos);
197 chainman.CheckBlockIndex();
205 chainman.m_best_header = genesis;
206 chainman.ResetBestInvalid();
207 chainman.nBlockSequenceId = 2;
208 chainman.ActiveChain().SetTip(*genesis);
209 chainman.ActiveChainstate().setBlockIndexCandidates.clear();
210 chainman.m_cached_is_ibd =
true;
216 for (
auto it =
blockman.m_block_index.begin(); it !=
blockman.m_block_index.end();) {
218 it =
blockman.m_block_index.erase(it);
223 chainman.ActiveChainstate().TryAddBlockIndexCandidate(genesis);
225 assert(chainman.ActiveChainstate().setBlockIndexCandidates.size() == 1);
226 assert(chainman.ActiveChain().Height() == 0);
CBlockHeader ConsumeBlockHeader(FuzzedDataProvider &provider, uint256 prev_hash, int &nonce_counter)
void initialize_block_index_tree()
const TestingSetup * g_setup
@ BLOCK_VALID_TRANSACTIONS
Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid,...
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok.
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous.
@ BLOCK_HAVE_UNDO
undo data available in rev*.dat
@ BLOCK_HAVE_DATA
full block available in blk*.dat
@ BLOCK_FAILED_VALID
stage after last reached validness failed
const CChainParams & Params()
Return the currently selected parameters.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
uint256 GetBlockHash() const
unsigned int nTx
Number of transactions in this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
const CBlock & GenesisBlock() const
T ConsumeIntegralInRange(T min, T max)
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
@ BLOCK_CONSENSUS
invalid by consensus rules (excluding any below reasons)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Testing setup that configures a complete environment.
std::unique_ptr< ChainstateManager > chainman
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider