Bitcoin ABC  0.22.13
P2P Digital Currency
Classes | Functions | Variables
chain.h File Reference
#include <arith_uint256.h>
#include <blockindex.h>
#include <blockstatus.h>
#include <blockvalidity.h>
#include <consensus/params.h>
#include <crypto/common.h>
#include <flatfile.h>
#include <primitives/block.h>
#include <sync.h>
#include <tinyformat.h>
#include <uint256.h>
#include <unordered_map>
#include <vector>
Include dependency graph for chain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BlockHasher
 Maintain a map of CBlockIndex for all known headers. More...
 
class  CDiskBlockIndex
 Used to marshal pointers into hashes for db storage. More...
 
class  CChain
 An in-memory indexed chain of blocks. More...
 

Functions

arith_uint256 GetBlockProof (const CBlockIndex &block)
 
int64_t GetBlockProofEquivalentTime (const CBlockIndex &to, const CBlockIndex &from, const CBlockIndex &tip, const Consensus::Params &)
 Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. More...
 
const CBlockIndexLastCommonAncestor (const CBlockIndex *pa, const CBlockIndex *pb)
 Find the forking point between two chain tips. More...
 
bool AreOnTheSameFork (const CBlockIndex *pa, const CBlockIndex *pb)
 Check if two block index are on the same fork. More...
 

Variables

static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60
 Maximum amount of time that a block timestamp is allowed to exceed the current network-adjusted time before the block will be accepted. More...
 
static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME
 Timestamp window used as a grace period by code that compares external timestamps (such as timestamps passed to RPCs, or wallet key creation times) to block timestamps. More...
 
static constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60
 Maximum gap between node time and block time used for the "Catching up..." mode in GUI. More...
 
RecursiveMutex cs_main
 Global state. More...
 

Function Documentation

◆ AreOnTheSameFork()

bool AreOnTheSameFork ( const CBlockIndex pa,
const CBlockIndex pb 
)

Check if two block index are on the same fork.

Definition at line 142 of file chain.cpp.

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

◆ GetBlockProof()

arith_uint256 GetBlockProof ( const CBlockIndex block)

Definition at line 80 of file chain.cpp.

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

◆ GetBlockProofEquivalentTime()

int64_t GetBlockProofEquivalentTime ( const CBlockIndex to,
const CBlockIndex from,
const CBlockIndex tip,
const Consensus::Params  
)

Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds.

Definition at line 95 of file chain.cpp.

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

◆ LastCommonAncestor()

const CBlockIndex* LastCommonAncestor ( const CBlockIndex pa,
const CBlockIndex pb 
)

Find the forking point between two chain tips.

Find the forking point between two chain tips.

Both pa and pb must be non null.

Definition at line 118 of file chain.cpp.

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

Variable Documentation

◆ cs_main

RecursiveMutex cs_main

Global state.

Mutex to guard access to validation specific variables, such as reading or changing the chainstate.

This may also need to be locked when updating the transaction pool, e.g. on AcceptToMemoryPool. See CTxMemPool::cs comment for details.

The transaction pool has a separate lock to allow reading from it and the chainstate at the same time.

Definition at line 95 of file validation.cpp.

◆ MAX_BLOCK_TIME_GAP

constexpr int64_t MAX_BLOCK_TIME_GAP = 90 * 60
static

Maximum gap between node time and block time used for the "Catching up..." mode in GUI.

Ref: https://github.com/bitcoin/bitcoin/pull/1026

Definition at line 44 of file chain.h.

◆ MAX_FUTURE_BLOCK_TIME

constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60
static

Maximum amount of time that a block timestamp is allowed to exceed the current network-adjusted time before the block will be accepted.

Definition at line 28 of file chain.h.

◆ TIMESTAMP_WINDOW

constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME
static

Timestamp window used as a grace period by code that compares external timestamps (such as timestamps passed to RPCs, or wallet key creation times) to block timestamps.

This should be set at least as high as MAX_FUTURE_BLOCK_TIME.

Definition at line 36 of file chain.h.