Bitcoin Core
28.99.0
P2P Digital Currency
src
kernel
chain.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022 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 <
chain.h
>
6
#include <
interfaces/chain.h
>
7
#include <
kernel/chain.h
>
8
#include <
sync.h
>
9
#include <
uint256.h
>
10
11
class
CBlock
;
12
13
namespace
kernel
{
14
interfaces::BlockInfo
MakeBlockInfo
(
const
CBlockIndex
* index,
const
CBlock
*
data
)
15
{
16
interfaces::BlockInfo
info{index ? *index->
phashBlock
:
uint256::ZERO
};
17
if
(index) {
18
info.prev_hash = index->
pprev
? index->
pprev
->
phashBlock
:
nullptr
;
19
info.height = index->
nHeight
;
20
info.chain_time_max = index->
GetBlockTimeMax
();
21
LOCK
(
::cs_main
);
22
info.file_number = index->nFile;
23
info.data_pos = index->nDataPos;
24
}
25
info.data =
data
;
26
return
info;
27
}
28
}
// namespace kernel
29
30
std::ostream&
operator<<
(std::ostream& os,
const
ChainstateRole
& role) {
31
switch
(role) {
32
case
ChainstateRole::NORMAL
: os <<
"normal"
;
break
;
33
case
ChainstateRole::ASSUMEDVALID
: os <<
"assumedvalid"
;
break
;
34
case
ChainstateRole::BACKGROUND
: os <<
"background"
;
break
;
35
default
: os.setstate(std::ios_base::failbit);
36
}
37
return
os;
38
}
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:141
CBlockIndex::pprev
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition:
chain.h:147
CBlockIndex::GetBlockTimeMax
int64_t GetBlockTimeMax() const
Definition:
chain.h:271
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition:
chain.h:153
CBlockIndex::phashBlock
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition:
chain.h:144
uint256::ZERO
static const uint256 ZERO
Definition:
uint256.h:198
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
chain.h
operator<<
std::ostream & operator<<(std::ostream &os, const ChainstateRole &role)
Definition:
chain.cpp:30
chain.h
ChainstateRole
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
Definition:
chain.h:25
ChainstateRole::NORMAL
@ NORMAL
ChainstateRole::ASSUMEDVALID
@ ASSUMEDVALID
ChainstateRole::BACKGROUND
@ BACKGROUND
kernel
Definition:
coinstatsindex.h:13
kernel::MakeBlockInfo
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex *index, const CBlock *data)
Return data from block index.
Definition:
chain.cpp:14
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:78
sync.h
LOCK
#define LOCK(cs)
Definition:
sync.h:257
uint256.h
Generated on Wed Dec 18 2024 20:00:13 for Bitcoin Core by
1.9.4