Structs



  • | An in-memory indexed chain of blocks. |
  • | ChainState stores and provides an | API to update our local knowledge of | the current best chain. | | Eventually, the API here is targeted | at being exposed externally as a consumable | libconsensus library, so any functions | added must only call other class member | functions, pure functions in other | parts of the consensus library, callbacks | via the validation interface, or read/write-to-disk | functions (eventually this will also | be via callbacks). | | Anything that is contingent on the current | tip of the chain is stored here, whereas | block information and metadata independent | of the current tip is kept in BlockManager. |
  • | CoinStatsIndex maintains statistics | on the UTXO set. |


  • | Sort eviction candidates by network/localhost | and connection uptime. | | Candidates near the beginning are more | likely to be evicted, and those near | the end are more likely to be protected, | e.g. less likely to be evicted. | | - First, nodes that are not is_local | and that do not belong to network, | sorted by increasing uptime (from most | recently connected to connected longer). | | - Then, nodes that are is_local or | belong to network, sorted by increasing | uptime. |
  • | We put the arguments we’re handed into | a struct, so we can pass them around easier. |
  • | All the intermediate state that gets | passed between the various levels of | checking a given transaction. |
  • | Legacy class used for deserializing | vtxPrev for backwards compatibility. | vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, | but old wallet.dat files may still contain | vtxPrev vectors of CMerkleTxs. | | These need to get deserialized for field | alignment when deserializing a CWalletTx, | but the deserialized values are discarded.* |
  • | NodeContext struct containing references to | chain state and connection state. | | This is used by init, rpc, and test code to | pass object references around without needing | to declare the same variables and parameters | repeatedly, or to use globals. | | More variables could be added to this struct | (particularly references to validation | objects) to eliminate use of globals and make | code more modular and testable. The struct | isn’t intended to have any member functions. | | It should just be a collection of references | that can be used without pulling in unwanted | dependencies or functionality.

  • | TxIndex is used to look up transactions | included in the blockchain by hash. | | The index is written to a LevelDB database | and records the filesystem location | of each transaction by transaction | hash. |
  • | Access to the txindex database | (indexes/txindex/) |
  • | RAII wrapper for VerifyDB: Verify consistency | of the block and coin databases |

Enums

Constants

  • | Maximum witness length for Bech32 addresses. |
  • | Maximum size of the cfheaders cache | | We have a limit to prevent a bug in filling | this cache potentially turning into | an OOM. At 2000 entries, this cache is | big enough for a 2,000,000 length block | chain, which we should be enough until | ~2047. |
  • | The index database stores three items | for each block: the disk location of | the encoded filter, its dSHA256 hash, | and the header. Those belonging to blocks | on the active chain are indexed by height, | and those belonging to blocks that have | been reorganized out of the active chain | are indexed by block hash. This ensures | that filter data for any block that becomes | part of the active chain can always be | retrieved, alleviating timing concerns. | | The filters themselves are stored in | flat files and referenced by the LevelDB | entries. This minimizes the amount | of data written to LevelDB and keeps | the database values constant size. | The disk location of the next block filter | to be written (represented as a FlatFilePos) | is stored under the DB_FILTER_POS key. | | Keys for the height index have the type | [DB_BLOCK_HEIGHT, uint32 (BE)]. The | height is represented as big-endian | so that sequential reads of filters | by height are fast. | | Keys for the hash index have the type | [DB_BLOCK_HASH, uint256]. |
  • | The pre-allocation chunk size for fltr?????.dat | files |

Functions


  • | 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. | | ———– | @param[in] node | | reference to node context | ––––– | @param[in] tx | | the transaction to broadcast | ––––– | @param[out] err_string | | reference to std::string to fill with | error string if available | ––––– | @param[in] max_tx_fee | | reject txs with fees higher than this | (if 0, accept any fee) | ––––– | @param[in] relay | | flag if both mempool insertion and p2p | relay are requested | ––––– | @param[in] wait_callback | | wait until callbacks have been processed | to avoid stale result due to a sequentially | RPC. return error |
  • | Pushes a function to callback onto the | notification queue, guaranteeing | any callbacks generated prior to now | are finished when the function is called. | | Be very careful blocking on func to be | called if any locks are held - validation | interface clients may not be able to | make progress as they often wait for | things like cs_main, so blocking until | func is called with cs_main will result | in a deadlock (that DEBUG_LOCKORDER | will miss). |
  • | Context-dependent validity checks. | | By “context”, we mean only the previous | block headers, but not the UTXO set; | UTXO-related validity checks are done | in ConnectBlock(). | | ———– | @note | | This function is not currently invoked | by ConnectBlock(), so we should consider | upgrade issues if we change which consensus | rules are enforced in this function | (eg by adding a new consensus rule). | See comment in ConnectBlock(). | ––––– | @note | | -reindex-chainstate skips the validation | that happens here! |
  • | Build the genesis block. Note that the | output of its generation transaction | cannot be spent since it did not originally | exist in the database. | | ———– | @code | | CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1) | CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0) | CTxIn(OutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73) | CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B) | vMerkleTree: 4a5e1e |
  • | Return the expected assumeutxo value | for a given height, if one exists. | | ———– | @param[in] height | | Get the assumeutxo value for this height. | | ———– | @return | | empty if no assumeutxo configuration | exists for the given height. |
  • | Return transaction with a given hash. | | 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. | | ———– | @param[in] block_index | | The block to read from disk, or nullptr | ––––– | @param[in] mempool | | If provided, check mempool for tx | ––––– | @param[in] hash | | The txid | ––––– | @param[in] consensusParams | | The params | ––––– | @param[out] hashBlock | | The block hash, if the tx was found via | -txindex or block_index | | ———– | @return | | The tx if found, otherwise nullptr |
  • | Guess verification progress (as a fraction | between 0.0=genesis and 1.0=current | tip). |
  • | Load the mempool from disk. |
  • | Return implementation of Chain interface. |
  • | Return implementation of Init interface | for the gui process. |
  • | Return implementation of Init interface for | the node process. | | If the argv indicates that this is a child | process spawned to handle requests from | a parent process, this blocks and handles | requests, then returns null and a status code | to exit with. | | If this returns non-null, the caller can start | up normally and use the Init object to spawn | and connect to other processes while it is | running.
  • | Return implementation of Init interface | for the wallet process. |
  • | Parse a hex string into 256 bits | | ———– | @param[in] strHex | | a hex-formatted, 64-character string | ––––– | @param[out] result | | the result of the parsing | | ———– | @return | | true if successful, false if not @see | ParseHashV for an RPC-oriented version | of this |
  • | Atomically test acceptance of a package. | If the package only contains one tx, | package rules still apply. Package | validation does not allow BIP125 replacements, | so the transaction(s) cannot spend | the same inputs as any transaction in | the mempool. | | ———– | @param[in] txns | | Group of transactions which may be independent | or contain parent-child dependencies. | The transactions must not conflict | with each other, i.e., must not spend | the same inputs. If any dependencies | exist, parents must appear anywhere | in the list before their children. | | ———– | @return | | a PackageMempoolAcceptResult which | includes a MempoolAcceptResult for | each transaction. | | If a transaction fails, validation | will exit early and some results may | be missing. |
  • | Prune block files up to a given height | | This function is called from the RPC | code for pruneblockchain |
  • | Register subscriber |
  • | Register subscriber |
  • | Remove wallet name from persistent | configuration so it will not be loaded | on startup. |
  • | This is a synonym for the following, | which asserts certain locks are not | held: | | std::promise<c_void> promise; | CallFunctionInValidationInterfaceQueue([&promise] { | promise.set_value(); | }); | promise.get_future().wait(); |
  • | Check a block is completely valid from | start to finish (only works on top of | our current best block) |
  • | Test whether the LockPoints height | and time are still valid on the current | chain |
  • | Unload database information | | May NOT be used after any connections | are up as much of the peer-processing | logic assumes a consistent block index | state |
  • | Unregister all subscribers |
  • | Unregister subscriber |
  • | Unregister subscriber. DEPRECATED. | This is not safe to use when the RPC server | or main message handler thread is running. |

Type Definitions