LCOV - code coverage report
Current view: top level - src/index - timestampindex_types.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 22 22 100.0 %
Date: 2026-06-25 07:23:43 Functions: 9 9 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2015 The Bitcoin Core developers
       3             : // Copyright (c) 2016 BitPay Inc.
       4             : // Copyright (c) 2023-2026 The Dash Core developers
       5             : // Distributed under the MIT software license, see the accompanying
       6             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       7             : 
       8             : #ifndef BITCOIN_INDEX_TIMESTAMPINDEX_TYPES_H
       9             : #define BITCOIN_INDEX_TIMESTAMPINDEX_TYPES_H
      10             : 
      11             : #include <serialize.h>
      12             : #include <uint256.h>
      13             : 
      14             : struct CTimestampIndexIteratorKey {
      15             :     uint32_t m_time{0};
      16             : 
      17             :     CTimestampIndexIteratorKey() = default;
      18           8 :     explicit CTimestampIndexIteratorKey(uint32_t time) :
      19           4 :         m_time{time}
      20           4 :     {
      21           8 :     }
      22             : 
      23             :     void SetNull() { m_time = 0; }
      24             : 
      25             :     static size_t GetSerializeSize(int nType, int nVersion) { return 4; }
      26             : 
      27             :     template <typename Stream>
      28           4 :     void Serialize(Stream& s) const
      29             :     {
      30           4 :         ser_writedata32be(s, m_time);
      31           4 :     }
      32             : 
      33             :     template <typename Stream>
      34             :     void Unserialize(Stream& s)
      35             :     {
      36             :         m_time = ser_readdata32be(s);
      37             :     }
      38             : };
      39             : 
      40             : struct CTimestampIndexKey {
      41          30 :     uint32_t m_block_time{0};
      42             :     uint256 m_block_hash;
      43             : 
      44          90 :     CTimestampIndexKey() = default;
      45         840 :     CTimestampIndexKey(uint32_t block_time, uint256 block_hash) :
      46         420 :         m_block_time{block_time},
      47         420 :         m_block_hash{block_hash}
      48         420 :     {
      49         840 :     }
      50             : 
      51             :     void SetNull()
      52             :     {
      53             :         m_block_time = 0;
      54             :         m_block_hash.SetNull();
      55             :     }
      56             : 
      57             :     static size_t GetSerializeSize(int nType, int nVersion) { return 36; }
      58             : 
      59             :     template <typename Stream>
      60         426 :     void Serialize(Stream& s) const
      61             :     {
      62         426 :         ser_writedata32be(s, m_block_time);
      63         426 :         m_block_hash.Serialize(s);
      64         426 :     }
      65             : 
      66             :     template <typename Stream>
      67          18 :     void Unserialize(Stream& s)
      68             :     {
      69          18 :         m_block_time = ser_readdata32be(s);
      70          18 :         m_block_hash.Unserialize(s);
      71          18 :     }
      72             : };
      73             : 
      74             : #endif // BITCOIN_INDEX_TIMESTAMPINDEX_TYPES_H

Generated by: LCOV version 1.16