Bitcoin Core
30.99.0
P2P Digital Currency
src
test
util
validation.h
Go to the documentation of this file.
1
// Copyright (c) 2020-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_TEST_UTIL_VALIDATION_H
6
#define BITCOIN_TEST_UTIL_VALIDATION_H
7
8
#include <
validation.h
>
9
10
namespace
node
{
11
class
BlockManager;
12
}
13
class
CValidationInterface
;
14
15
struct
TestBlockManager
:
public
node::BlockManager
{
17
void
CleanupForFuzzing
();
18
};
19
20
struct
TestChainstateManager
:
public
ChainstateManager
{
22
void
DisableNextWrite
();
24
void
ResetIbd
();
26
void
JumpOutOfIbd
();
28
void
InvalidBlockFound
(
CBlockIndex
* pindex,
const
BlockValidationState
& state)
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
);
29
void
InvalidChainFound
(
CBlockIndex
* pindexNew)
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
);
30
CBlockIndex
*
FindMostWorkChain
()
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
);
31
void
ResetBestInvalid
()
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
);
32
};
33
34
class
ValidationInterfaceTest
35
{
36
public
:
37
static
void
BlockConnected
(
38
const
kernel::ChainstateRole
& role,
39
CValidationInterface
& obj,
40
const
std::shared_ptr<const CBlock>& block,
41
const
CBlockIndex
* pindex);
42
};
43
44
#endif
// BITCOIN_TEST_UTIL_VALIDATION_H
BlockValidationState
Definition:
validation.h:126
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition:
chain.h:95
CValidationInterface
Implement this to subscribe to events generated in validation and mempool.
Definition:
validationinterface.h:49
ChainstateManager
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Definition:
validation.h:930
ValidationInterfaceTest
Definition:
validation.h:35
ValidationInterfaceTest::BlockConnected
static void BlockConnected(const kernel::ChainstateRole &role, CValidationInterface &obj, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
Definition:
validation.cpp:46
node::BlockManager
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition:
blockstorage.h:191
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition:
cs_main.cpp:8
node
Definition:
messages.h:21
TestBlockManager
Definition:
validation.h:15
TestBlockManager::CleanupForFuzzing
void CleanupForFuzzing()
Test-only method to clear internal state for fuzzing.
Definition:
validation.cpp:15
TestChainstateManager
Definition:
validation.h:20
TestChainstateManager::ResetBestInvalid
void ResetBestInvalid() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition:
validation.cpp:90
TestChainstateManager::InvalidChainFound
void InvalidChainFound(CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition:
validation.cpp:66
TestChainstateManager::FindMostWorkChain
CBlockIndex * FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition:
validation.cpp:78
TestChainstateManager::DisableNextWrite
void DisableNextWrite()
Disable the next write of all chainstates.
Definition:
validation.cpp:22
TestChainstateManager::InvalidBlockFound
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Wrappers that avoid making chainstatemanager internals public for tests.
Definition:
validation.cpp:54
TestChainstateManager::JumpOutOfIbd
void JumpOutOfIbd()
Toggle IsInitialBlockDownload from true to false.
Definition:
validation.cpp:39
TestChainstateManager::ResetIbd
void ResetIbd()
Reset the ibd cache to its initial state.
Definition:
validation.cpp:33
kernel::ChainstateRole
Information about chainstate that notifications are sent from.
Definition:
types.h:18
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition:
threadsafety.h:51
validation.h
Generated on Fri Jan 2 2026 20:00:31 for Bitcoin Core by
1.9.4