Bitcoin Core
25.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 <
sync.h
>
8
#include <
uint256.h
>
9
10
class
CBlock
;
11
12
namespace
kernel
{
13
interfaces::BlockInfo
MakeBlockInfo
(
const
CBlockIndex
* index,
const
CBlock
* data)
14
{
15
interfaces::BlockInfo
info{index ? *index->
phashBlock
:
uint256::ZERO
};
16
if
(index) {
17
info.prev_hash = index->
pprev
? index->
pprev
->
phashBlock
:
nullptr
;
18
info.height = index->
nHeight
;
19
info.chain_time_max = index->
GetBlockTimeMax
();
20
LOCK
(::
cs_main
);
21
info.file_number = index->nFile;
22
info.data_pos = index->nDataPos;
23
}
24
info.data = data;
25
return
info;
26
}
27
}
// 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:159
CBlockIndex::pprev
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition:
chain.h:165
CBlockIndex::GetBlockTimeMax
int64_t GetBlockTimeMax() const
Definition:
chain.h:292
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition:
chain.h:171
CBlockIndex::phashBlock
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition:
chain.h:162
uint256::ZERO
static const uint256 ZERO
Definition:
uint256.h:111
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
chain.h
kernel
Definition:
coinstatsindex.h:13
kernel::MakeBlockInfo
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex *index, const CBlock *data)
Return data from block index.
Definition:
chain.cpp:13
interfaces::BlockInfo
Block data sent with blockConnected, blockDisconnected notifications.
Definition:
chain.h:82
sync.h
LOCK
#define LOCK(cs)
Definition:
sync.h:258
uint256.h
Generated on Fri Sep 29 2023 20:02:27 for Bitcoin Core by
1.9.1