Bitcoin Core
30.99.0
P2P Digital Currency
src
kernel
chain.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
kernel/chain.h
>
6
7
#include <
chain.h
>
8
#include <
kernel/cs_main.h
>
9
#include <
kernel/types.h
>
10
#include <
sync.h
>
11
#include <
uint256.h
>
12
13
class
CBlock
;
14
15
using
kernel::ChainstateRole
;
16
17
namespace
kernel
{
18
interfaces::BlockInfo
MakeBlockInfo
(
const
CBlockIndex
* index,
const
CBlock
*
data
)
19
{
20
interfaces::BlockInfo
info{index ? *index->
phashBlock
:
uint256::ZERO
};
21
if
(index) {
22
info.prev_hash = index->
pprev
? index->
pprev
->
phashBlock
:
nullptr
;
23
info.height = index->
nHeight
;
24
info.chain_time_max = index->
GetBlockTimeMax
();
25
LOCK
(
::cs_main
);
26
info.file_number = index->nFile;
27
info.data_pos = index->nDataPos;
28
}
29
info.data =
data
;
30
return
info;
31
}
32
33
std::ostream&
operator<<
(std::ostream& os,
const
ChainstateRole
& role) {
34
if
(!role.
validated
) {
35
os <<
"assumedvalid"
;
36
}
else
if
(role.
historical
) {
37
os <<
"background"
;
38
}
else
{
39
os <<
"normal"
;
40
}
41
return
os;
42
}
43
}
// namespace kernel
CBlock
Definition:
block.h:69
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition:
chain.h:95
CBlockIndex::pprev
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition:
chain.h:101
CBlockIndex::GetBlockTimeMax
int64_t GetBlockTimeMax() const
Definition:
chain.h:227
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition:
chain.h:107
CBlockIndex::phashBlock
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition:
chain.h:98
uint256::ZERO
static const uint256 ZERO
Definition:
uint256.h:203
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition:
cs_main.cpp:8
cs_main.h
chain.h
types.h
is a home for simple enum and struct type definitions that can be used internally by functions in the...
kernel
Definition:
coinstatsindex.h:21
kernel::MakeBlockInfo
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex *index, const CBlock *data)
Return data from block index.
Definition:
chain.cpp:18
kernel::operator<<
std::ostream & operator<<(std::ostream &os, const ChainstateRole &role)
Definition:
chain.cpp:33
test_vectors_musig2_generate.data
data
Definition:
test_vectors_musig2_generate.py:98
interfaces::BlockInfo
Block data sent with blockConnected, blockDisconnected notifications.
Definition:
chain.h:19
kernel::ChainstateRole
Information about chainstate that notifications are sent from.
Definition:
types.h:18
kernel::ChainstateRole::validated
bool validated
Whether this is a notification from a chainstate that's been fully validated starting from the genesi...
Definition:
types.h:22
kernel::ChainstateRole::historical
bool historical
Whether this is a historical chainstate downloading old blocks to validate an assumeutxo snapshot,...
Definition:
types.h:26
sync.h
LOCK
#define LOCK(cs)
Definition:
sync.h:259
uint256.h
Generated on Mon Dec 22 2025 20:00:31 for Bitcoin Core by
1.9.4