/root/bitcoin/src/kernel/chain.cpp
Line | Count | Source |
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 | 0 | { |
20 | 0 | interfaces::BlockInfo info{index ? *index->phashBlock : uint256::ZERO}; |
21 | 0 | if (index) { |
22 | 0 | info.prev_hash = index->pprev ? index->pprev->phashBlock : nullptr; |
23 | 0 | info.height = index->nHeight; |
24 | 0 | info.chain_time_max = index->GetBlockTimeMax(); |
25 | 0 | LOCK(::cs_main); Line | Count | Source | 266 | 0 | #define LOCK(cs) UniqueLock UNIQUE_NAME(criticalblock)(MaybeCheckNotHeld(cs), #cs, __FILE__, __LINE__) Line | Count | Source | 11 | 0 | #define UNIQUE_NAME(name) PASTE2(name, __COUNTER__) Line | Count | Source | 9 | 0 | #define PASTE2(x, y) PASTE(x, y) Line | Count | Source | 8 | 0 | #define PASTE(x, y) x ## y |
|
|
|
|
26 | 0 | info.file_number = index->nFile; |
27 | 0 | info.data_pos = index->nDataPos; |
28 | 0 | } |
29 | 0 | info.data = data; |
30 | 0 | return info; |
31 | 0 | } |
32 | | |
33 | 0 | std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) { |
34 | 0 | if (!role.validated) { |
35 | 0 | os << "assumedvalid"; |
36 | 0 | } else if (role.historical) { |
37 | 0 | os << "background"; |
38 | 0 | } else { |
39 | 0 | os << "normal"; |
40 | 0 | } |
41 | 0 | return os; |
42 | 0 | } |
43 | | } // namespace kernel |