Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2022-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <kernel/chain.h>7#include <chain.h>8#include <kernel/cs_main.h>9#include <kernel/types.h>10#include <sync.h>11#include <uint256.h>13class CBlock;15using kernel::ChainstateRole;17namespace kernel {18interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data)19{20interfaces::BlockInfo info{index ? *index->phashBlock : uint256::ZERO};21if (index) {22info.prev_hash = index->pprev ? index->pprev->phashBlock : nullptr;23info.height = index->nHeight;24info.chain_time_max = index->GetBlockTimeMax();25LOCK(::cs_main);26info.file_number = index->nFile;27info.data_pos = index->nDataPos;28}29info.data = data;30return info;31}33std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) {34if (!role.validated) {35os << "assumedvalid";36} else if (role.historical) {37os << "background";38} else {39os << "normal";40}41return os;42}43} // namespace kernel