Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.88 KB

locating-consensus-code.adoc

File metadata and controls

53 lines (40 loc) · 1.88 KB

Consensus in Bitcoin Core

Naturally one might assume that all code related to consensus could be found in the src/consensus/ directory, however this is not entirely the case. Components of consensus-related code can be found across the Bitcoin Core codebase in a number of files, including but not limited to:

📂 bitcoin
  📂 src
    📂 consensus
    📂 script
      📄interpreter.cpp
    📄 validation.h
    📄 validation.cpp

Consensus-critical functions can also be found in proximity to code which could affect whether a node considers a transaction or block valid. This could extend to, for example, block storage database code.

An abbreviated list of some of the more notable consensus functions and variables is shown below.

Table 1. Some consensus functions and variables
File Objects

src/consensus/amount.h

COIN, MAX_MONEY, MoneyRange()

src/consensus/consensus.h

BLOCK{SIZE|WEIGHT|SIGOPS_COST}, COINBASE_MATURITY, WITNESS_SCALE_FACTOR, MIN_TX_WEIGHT

src/consensus/merkle.{h|cpp}

ComputeMerkleRoot(), BlockMerkleRoot(), BlockWitnessMerkleRoot()

src/consensus/params.h

BuriedDeployment, Params(buried blocks which are valid but known to fail default script verify checks, BIP height activations, PoW params)

src/consensus/tx_check.{h|cpp}

CheckTransaction()

src/consensus/tx_verify.{h|cpp}

CheckTxInputs(), Get{Legacy}SigOpCount(), IsFinalTx(), SequenceLock(s)()

src/consensus/validation.h

TxValidationResult (validation result reason), BlockValidationResult (validation result reason), ValidationState, Get{Transaction|Block|TransactionInput}Weight()