/bitcoin/src/kernel/chain.cpp
Line | Count | Source |
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 | 4.46M | { |
16 | 4.46M | interfaces::BlockInfo info{index ? *index->phashBlock : uint256::ZERO}; Branch (16:32): [True: 4.46M, False: 0]
|
17 | 4.46M | if (index) { Branch (17:9): [True: 4.46M, False: 0]
|
18 | 4.46M | info.prev_hash = index->pprev ? index->pprev->phashBlock : nullptr; Branch (18:26): [True: 4.45M, False: 11.0k]
|
19 | 4.46M | info.height = index->nHeight; |
20 | 4.46M | info.chain_time_max = index->GetBlockTimeMax(); |
21 | 4.46M | LOCK(::cs_main); |
22 | 4.46M | info.file_number = index->nFile; |
23 | 4.46M | info.data_pos = index->nDataPos; |
24 | 4.46M | } |
25 | 4.46M | info.data = data; |
26 | 4.46M | return info; |
27 | 4.46M | } |
28 | | } // namespace kernel |
29 | | |
30 | 0 | std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) { |
31 | 0 | switch(role) { |
32 | 0 | case ChainstateRole::NORMAL: os << "normal"; break; Branch (32:9): [True: 0, False: 0]
|
33 | 0 | case ChainstateRole::ASSUMEDVALID: os << "assumedvalid"; break; Branch (33:9): [True: 0, False: 0]
|
34 | 0 | case ChainstateRole::BACKGROUND: os << "background"; break; Branch (34:9): [True: 0, False: 0]
|
35 | 0 | default: os.setstate(std::ios_base::failbit); Branch (35:9): [True: 0, False: 0]
|
36 | 0 | } |
37 | 0 | return os; |
38 | 0 | } |