Bitcoin ABC  0.26.3
P2P Digital Currency
Classes | Typedefs | Enumerations | Functions | Variables
node Namespace Reference

Classes

class  ImportingNow
 
struct  PruneLockInfo
 
class  BlockManager
 Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-work tip is. More...
 
struct  CacheSizes
 
struct  ChainstateLoadOptions
 
struct  NodeContext
 NodeContext struct containing references to chain state and connection state. More...
 
class  KernelNotifications
 
struct  CBlockTemplateEntry
 
struct  CBlockTemplate
 
class  BlockAssembler
 Generate a new block, without valid proof-of-work. More...
 
struct  PSBTInputAnalysis
 Holds an analysis of one input from a PSBT. More...
 
struct  PSBTAnalysis
 Holds the results of AnalyzePSBT (miscellaneous information about a PSBT) More...
 
class  SnapshotMetadata
 Metadata describing a serialized version of a UTXO set from which an assumeutxo Chainstate can be constructed. More...
 

Typedefs

using BlockMap = std::unordered_map< BlockHash, CBlockIndex, BlockHasher >
 
using ChainstateLoadResult = std::tuple< ChainstateLoadStatus, bilingual_str >
 Chainstate load status code and optional error string. More...
 

Enumerations

enum class  ChainstateLoadStatus {
  SUCCESS , FAILURE , FAILURE_FATAL , FAILURE_INCOMPATIBLE_DB ,
  FAILURE_INSUFFICIENT_DBCACHE , INTERRUPTED
}
 Chainstate load status. More...
 

Functions

std::optional< bilingual_strApplyArgsManOptions (const ArgsManager &args, BlockManager::Options &opts)
 
std::atomic_bool fReindex (false)
 
void ThreadImport (ChainstateManager &chainman, avalanche::Processor *const avalanche, std::vector< fs::path > vImportFiles, const fs::path &mempool_path)
 
CacheSizes CalculateCacheSizes (const ArgsManager &args, size_t n_indexes)
 
static ChainstateLoadResult CompleteChainstateInitialization (ChainstateManager &chainman, const CacheSizes &cache_sizes, const ChainstateLoadOptions &options) EXCLUSIVE_LOCKS_REQUIRED(
 
ChainstateLoadResult LoadChainstate (ChainstateManager &chainman, const CacheSizes &cache_sizes, const ChainstateLoadOptions &options)
 This sequence can have 4 types of outcomes: More...
 
ChainstateLoadResult VerifyLoadedChainstate (ChainstateManager &chainman, const ChainstateLoadOptions &options)
 
std::optional< bilingual_strApplyArgsManOptions (const ArgsManager &args, ChainstateManager::Options &opts)
 
void FindCoins (const NodeContext &node, std::map< COutPoint, Coin > &coins)
 Look up unspent output information. More...
 
void ReadCoinsViewArgs (const ArgsManager &args, CoinsViewOptions &options)
 
std::optional< kernel::CCoinsStatsGetUTXOStats (CCoinsView *view, node::BlockManager &blockman, kernel::CoinStatsHashType hash_type, const std::function< void()> &interruption_point={}, const CBlockIndex *pindex=nullptr, bool index_requested=true)
 Calculate statistics about the unspent transaction output set. More...
 
void ReadDatabaseArgs (const ArgsManager &args, DBOptions &options)
 
bool ShouldPersistMempool (const ArgsManager &argsman)
 
fs::path MempoolPath (const ArgsManager &argsman)
 
int64_t UpdateTime (CBlockHeader *pblock, const CChainParams &chainParams, const CBlockIndex *pindexPrev)
 
static BlockAssembler::Options DefaultOptions (const Config &config)
 
PSBTAnalysis AnalyzePSBT (PartiallySignedTransaction psbtx)
 Provides helpful miscellaneous information about where a PSBT is in the signing workflow. More...
 
static TransactionError HandleATMPError (const TxValidationState &state, std::string &err_string_out)
 
TransactionError BroadcastTransaction (const NodeContext &node, CTransactionRef tx, std::string &err_string, Amount max_tx_fee, bool relay, bool wait_callback)
 Submit a transaction to the mempool and (optionally) relay it to all P2P peers. More...
 
CTransactionRef GetTransaction (const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, BlockHash &hashBlock, const BlockManager &blockman)
 Return transaction with a given txid. More...
 
bool WriteSnapshotBaseBlockhash (Chainstate &snapshot_chainstate)
 
std::optional< BlockHashReadSnapshotBaseBlockhash (const fs::path &chaindir)
 
std::optional< fs::pathFindSnapshotChainstateDir ()
 Return a path to the snapshot-based chainstate dir, if one exists. More...
 
void ApplyArgsManOptions (const ArgsManager &argsman, ValidationCacheSizes &cache_sizes)
 

Variables

static constexpr unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000
 The pre-allocation chunk size for blk?????.dat files (since 0.8) More...
 
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000
 The pre-allocation chunk size for rev?????.dat files (since 0.8) More...
 
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000
 The maximum size of a blk?????.dat file (since 0.8) More...
 
static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE
 Size of header written by WriteBlockToDisk before a serialized CBlock. More...
 
std::atomic_bool fReindex
 
static constexpr bool DEFAULT_PERSIST_MEMPOOL {true}
 Default for -persistmempool, indicating whether the node should attempt to automatically load the mempool on start and save to disk on shutdown. More...
 
static const bool DEFAULT_PRINTPRIORITY = false
 
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE {COIN / 10}
 Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls. More...
 
const fs::path SNAPSHOT_BLOCKHASH_FILENAME {"base_blockhash"}
 The file in the snapshot chainstate dir which stores the base blockhash. More...
 
bool WriteSnapshotBaseBlockhash(Chainstate &snapshot_chainstate) EXCLUSIVE_LOCKS_REQUIRED(std::optional< BlockHash > constexpr ReadSnapshotBaseBlockhash(const fs::path &chaindir) EXCLUSIVE_LOCKS_REQUIRED(std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot"
 Write out the blockhash of the snapshot base block that was used to construct this chainstate. More...
 

Typedef Documentation

◆ BlockMap

using node::BlockMap = typedef std::unordered_map<BlockHash, CBlockIndex, BlockHasher>

Definition at line 60 of file blockstorage.h.

◆ ChainstateLoadResult

Chainstate load status code and optional error string.

Definition at line 56 of file chainstate.h.

Enumeration Type Documentation

◆ ChainstateLoadStatus

Chainstate load status.

Simple applications can just check for the success case, and treat other cases as errors. More complex applications may want to try reindexing in the generic failure case, and pass an interrupt callback and exit cleanly in the interrupted case.

Enumerator
SUCCESS 
FAILURE 

Generic failure which reindexing may fix.

FAILURE_FATAL 

Fatal error which should not prompt to reindex.

FAILURE_INCOMPATIBLE_DB 
FAILURE_INSUFFICIENT_DBCACHE 
INTERRUPTED 

Definition at line 44 of file chainstate.h.

Function Documentation

◆ AnalyzePSBT()

PSBTAnalysis node::AnalyzePSBT ( PartiallySignedTransaction  psbtx)

Provides helpful miscellaneous information about where a PSBT is in the signing workflow.

Parameters
[in]psbtxthe PSBT to analyze
Returns
A PSBTAnalysis with information about the provided PSBT.

Definition at line 16 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ApplyArgsManOptions() [1/3]

std::optional< bilingual_str > node::ApplyArgsManOptions ( const ArgsManager args,
BlockManager::Options opts 
)

Definition at line 17 of file blockmanager_args.cpp.

Here is the call graph for this function:

◆ ApplyArgsManOptions() [2/3]

std::optional< bilingual_str > node::ApplyArgsManOptions ( const ArgsManager args,
ChainstateManager::Options opts 
)

Definition at line 24 of file chainstatemanager_args.cpp.

Here is the call graph for this function:

◆ ApplyArgsManOptions() [3/3]

void node::ApplyArgsManOptions ( const ArgsManager argsman,
ValidationCacheSizes cache_sizes 
)

Definition at line 20 of file validation_cache_args.cpp.

Here is the call graph for this function:

◆ BroadcastTransaction()

TransactionError node::BroadcastTransaction ( const NodeContext node,
CTransactionRef  tx,
std::string &  err_string,
Amount  max_tx_fee,
bool  relay,
bool  wait_callback 
)

Submit a transaction to the mempool and (optionally) relay it to all P2P peers.

Mempool submission can be synchronous (will await mempool entry notification over the CValidationInterface) or asynchronous (will submit and not wait for notification), depending on the value of wait_callback. wait_callback MUST NOT be set while cs_main, cs_mempool or cs_wallet are held to avoid deadlock.

Parameters
[in]nodereference to node context
[in]txthe transaction to broadcast
[out]err_stringreference to std::string to fill with error string if available
[in]max_tx_feereject txs with fees higher than this (if 0, accept any fee)
[in]relayflag if both mempool insertion and p2p relay are requested
[in]wait_callbackwait until callbacks have been processed to avoid stale result due to a sequentially RPC.
Returns
error

Definition at line 37 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateCacheSizes()

CacheSizes node::CalculateCacheSizes ( const ArgsManager args,
size_t  n_indexes 
)

Definition at line 12 of file caches.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompleteChainstateInitialization()

static ChainstateLoadResult node::CompleteChainstateInitialization ( ChainstateManager chainman,
const CacheSizes cache_sizes,
const ChainstateLoadOptions options 
)
static

Definition at line 18 of file chainstate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultOptions()

static BlockAssembler::Options node::DefaultOptions ( const Config config)
static

Definition at line 84 of file miner.cpp.

Here is the call graph for this function:

◆ FindCoins()

void node::FindCoins ( const NodeContext node,
std::map< COutPoint, Coin > &  coins 
)

Look up unspent output information.

Returns coins in the mempool and in the current chain UTXO set. Iterates through all the keys in the map and populates the values.

Parameters
[in]nodeThe node context to use for lookup
[in,out]coinsmap to fill

Definition at line 12 of file coin.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindSnapshotChainstateDir()

std::optional< fs::path > node::FindSnapshotChainstateDir ( )

Return a path to the snapshot-based chainstate dir, if one exists.

Definition at line 86 of file utxo_snapshot.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fReindex()

std::atomic_bool node::fReindex ( false  )

◆ GetTransaction()

CTransactionRef node::GetTransaction ( const CBlockIndex *const  block_index,
const CTxMemPool *const  mempool,
const TxId txid,
BlockHash hashBlock,
const BlockManager blockman 
)

Return transaction with a given txid.

If mempool is provided and block_index is not provided, check it first for the tx. If -txindex is available, check it next for the tx. Finally, if block_index is provided, check for tx by reading entire block from disk.

Parameters
[in]block_indexThe block to read from disk, or nullptr
[in]mempoolIf provided, check mempool for tx
[in]txidThe txid
[out]hashBlockThe block hash, if the tx was found via -txindex or block_index
Returns
The tx if found, otherwise nullptr

Definition at line 129 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUTXOStats()

std::optional< kernel::CCoinsStats > node::GetUTXOStats ( CCoinsView view,
node::BlockManager blockman,
kernel::CoinStatsHashType  hash_type,
const std::function< void()> &  interruption_point = {},
const CBlockIndex pindex = nullptr,
bool  index_requested = true 
)

Calculate statistics about the unspent transaction output set.

Parameters
[in]index_requestedSignals if the coinstatsindex should be used (when available).

Definition at line 16 of file coinstats.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleATMPError()

static TransactionError node::HandleATMPError ( const TxValidationState state,
std::string &  err_string_out 
)
static

Definition at line 24 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadChainstate()

ChainstateLoadResult node::LoadChainstate ( ChainstateManager chainman,
const CacheSizes cache_sizes,
const ChainstateLoadOptions options 
)

This sequence can have 4 types of outcomes:

  1. Success
  2. Shutdown requested
    • nothing failed but a shutdown was triggered in the middle of the sequence
  3. Soft failure
    • a failure that might be recovered from with a reindex
  4. Hard failure
    • a failure that definitively cannot be recovered from with a reindex

LoadChainstate returns a (status code, error string) tuple.

Definition at line 167 of file chainstate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MempoolPath()

fs::path node::MempoolPath ( const ArgsManager argsman)

Definition at line 17 of file mempool_persist_args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadCoinsViewArgs()

void node::ReadCoinsViewArgs ( const ArgsManager args,
CoinsViewOptions options 
)

Definition at line 11 of file coins_view_args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadDatabaseArgs()

void node::ReadDatabaseArgs ( const ArgsManager args,
DBOptions options 
)

Definition at line 11 of file database_args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSnapshotBaseBlockhash()

std::optional<BlockHash> node::ReadSnapshotBaseBlockhash ( const fs::path chaindir)

Definition at line 48 of file utxo_snapshot.cpp.

Here is the call graph for this function:

◆ ShouldPersistMempool()

bool node::ShouldPersistMempool ( const ArgsManager argsman)

Definition at line 13 of file mempool_persist_args.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThreadImport()

void node::ThreadImport ( ChainstateManager chainman,
avalanche::Processor *const  avalanche,
std::vector< fs::path vImportFiles,
const fs::path mempool_path 
)

Definition at line 914 of file blockstorage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateTime()

int64_t node::UpdateTime ( CBlockHeader pblock,
const CChainParams chainParams,
const CBlockIndex pindexPrev 
)

Definition at line 38 of file miner.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyLoadedChainstate()

ChainstateLoadResult node::VerifyLoadedChainstate ( ChainstateManager chainman,
const ChainstateLoadOptions options 
)

Definition at line 262 of file chainstate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteSnapshotBaseBlockhash()

bool node::WriteSnapshotBaseBlockhash ( Chainstate snapshot_chainstate)

Definition at line 19 of file utxo_snapshot.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BLOCK_SERIALIZATION_HEADER_SIZE

constexpr size_t node::BLOCK_SERIALIZATION_HEADER_SIZE
staticconstexpr
Initial value:
=
CMessageHeader::MESSAGE_START_SIZE + sizeof(unsigned int)
static constexpr size_t MESSAGE_START_SIZE
Definition: protocol.h:36

Size of header written by WriteBlockToDisk before a serialized CBlock.

Definition at line 51 of file blockstorage.h.

◆ BLOCKFILE_CHUNK_SIZE

constexpr unsigned int node::BLOCKFILE_CHUNK_SIZE = 0x1000000
staticconstexpr

The pre-allocation chunk size for blk?????.dat files (since 0.8)

Definition at line 44 of file blockstorage.h.

◆ DEFAULT_MAX_RAW_TX_FEE_RATE

const CFeeRate node::DEFAULT_MAX_RAW_TX_FEE_RATE {COIN / 10}
static

Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.

Also used by the GUI when broadcasting a completed PSBT. By default, a transaction with a fee rate higher than this will be rejected by these RPCs and the GUI. This can be overridden with the maxfeerate argument.

Definition at line 33 of file transaction.h.

◆ DEFAULT_PERSIST_MEMPOOL

constexpr bool node::DEFAULT_PERSIST_MEMPOOL {true}
staticconstexpr

Default for -persistmempool, indicating whether the node should attempt to automatically load the mempool on start and save to disk on shutdown.

Definition at line 18 of file mempool_persist_args.h.

◆ DEFAULT_PRINTPRIORITY

const bool node::DEFAULT_PRINTPRIORITY = false
static

Definition at line 35 of file miner.h.

◆ fReindex

std::atomic_bool node::fReindex
extern

◆ MAX_BLOCKFILE_SIZE

const unsigned int node::MAX_BLOCKFILE_SIZE = 0x8000000
static

The maximum size of a blk?????.dat file (since 0.8)

Definition at line 48 of file blockstorage.h.

◆ SNAPSHOT_BLOCKHASH_FILENAME

const fs::path node::SNAPSHOT_BLOCKHASH_FILENAME {"base_blockhash"}

The file in the snapshot chainstate dir which stores the base blockhash.

This is needed to reconstruct snapshot chainstates on init.

Because we only allow loading a single snapshot at a time, there will only be one chainstate directory with this filename present within it.

Definition at line 46 of file utxo_snapshot.h.

◆ SNAPSHOT_CHAINSTATE_SUFFIX

bool WriteSnapshotBaseBlockhash (Chainstate &snapshot_chainstate) EXCLUSIVE_LOCKS_REQUIRED( std::optional<BlockHash> constexpr ReadSnapshotBaseBlockhash (const fs::path &chaindir) EXCLUSIVE_LOCKS_REQUIRED( std::string_view node::SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot"
constexpr

Write out the blockhash of the snapshot base block that was used to construct this chainstate.

This value is read in during subsequent initializations and used to reconstruct snapshot-based chainstates. Read the blockhash of the snapshot base block that was used to construct the chainstate. Suffix appended to the chainstate (leveldb) dir when created based upon a snapshot.

Definition at line 61 of file utxo_snapshot.h.

◆ UNDOFILE_CHUNK_SIZE

const unsigned int node::UNDOFILE_CHUNK_SIZE = 0x100000
static

The pre-allocation chunk size for rev?????.dat files (since 0.8)

Definition at line 46 of file blockstorage.h.