LCOV - code coverage report
Current view: top level - src/kernel - chain.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 100.0 % 19 19
Test Date: 2025-12-28 05:09:18 Functions: 100.0 % 2 2
Branches: 75.0 % 12 9

             Branch data     Line data    Source code
       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                 :       81358 : interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data)
      19                 :             : {
      20         [ +  - ]:       81358 :     interfaces::BlockInfo info{index ? *index->phashBlock : uint256::ZERO};
      21         [ +  - ]:       81358 :     if (index) {
      22         [ +  + ]:       81358 :         info.prev_hash = index->pprev ? index->pprev->phashBlock : nullptr;
      23                 :       81358 :         info.height = index->nHeight;
      24                 :       81358 :         info.chain_time_max = index->GetBlockTimeMax();
      25                 :       81358 :         LOCK(::cs_main);
      26                 :       81358 :         info.file_number = index->nFile;
      27         [ +  - ]:       81358 :         info.data_pos = index->nDataPos;
      28                 :       81358 :     }
      29                 :       81358 :     info.data = data;
      30                 :       81358 :     return info;
      31                 :             : }
      32                 :             : 
      33                 :         510 : std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) {
      34         [ +  + ]:         510 :     if (!role.validated) {
      35                 :          14 :         os << "assumedvalid";
      36         [ +  + ]:         496 :     } else if (role.historical) {
      37                 :           4 :         os << "background";
      38                 :             :     } else {
      39                 :         492 :         os << "normal";
      40                 :             :     }
      41                 :         510 :     return os;
      42                 :             : }
      43                 :             : } // namespace kernel
        

Generated by: LCOV version 2.0-1