LCOV - code coverage report
Current view: top level - src/index - spentindex_types.h (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 0 37 0.0 %
Date: 2026-06-25 07:23:51 Functions: 0 25 0.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_SPENTINDEX_TYPES_H
       9             : #define BITCOIN_INDEX_SPENTINDEX_TYPES_H
      10             : 
      11             : #include <consensus/amount.h>
      12             : #include <index/addressindex_types.h>
      13             : #include <serialize.h>
      14             : #include <uint256.h>
      15             : 
      16             : #include <map>
      17             : #include <tuple>
      18             : 
      19             : struct CSpentIndexKey {
      20             : public:
      21             :     uint256 m_tx_hash;
      22           0 :     uint32_t m_tx_index{0};
      23             : 
      24             : public:
      25           0 :     CSpentIndexKey() { SetNull(); }
      26             : 
      27           0 :     CSpentIndexKey(uint256 txout_hash, uint32_t txout_index) :
      28           0 :         m_tx_hash{txout_hash},
      29           0 :         m_tx_index{txout_index} {};
      30             : 
      31           0 :     void SetNull()
      32             :     {
      33           0 :         m_tx_hash.SetNull();
      34           0 :         m_tx_index = 0;
      35           0 :     }
      36             : 
      37             : public:
      38           0 :     SERIALIZE_METHODS(CSpentIndexKey, obj) { READWRITE(obj.m_tx_hash, obj.m_tx_index); }
      39             : };
      40             : 
      41             : struct CSpentIndexValue {
      42             : public:
      43             :     uint256 m_tx_hash;
      44           0 :     uint32_t m_tx_index{0};
      45           0 :     int32_t m_block_height{0};
      46           0 :     CAmount m_amount{0};
      47           0 :     AddressType m_address_type{AddressType::UNKNOWN};
      48             :     uint160 m_address_bytes;
      49             : 
      50             : public:
      51           0 :     CSpentIndexValue() { SetNull(); }
      52             : 
      53           0 :     CSpentIndexValue(uint256 txin_hash, uint32_t txin_index, int32_t block_height, CAmount amount,
      54             :                      AddressType address_type, uint160 address_bytes) :
      55           0 :         m_tx_hash{txin_hash},
      56           0 :         m_tx_index{txin_index},
      57           0 :         m_block_height{block_height},
      58           0 :         m_amount{amount},
      59           0 :         m_address_type{address_type},
      60           0 :         m_address_bytes{address_bytes} {};
      61             : 
      62           0 :     void SetNull()
      63             :     {
      64           0 :         m_tx_hash.SetNull();
      65           0 :         m_tx_index = 0;
      66           0 :         m_block_height = 0;
      67           0 :         m_amount = 0;
      68           0 :         m_address_type = AddressType::UNKNOWN;
      69           0 :         m_address_bytes.SetNull();
      70           0 :     }
      71             : 
      72           0 :     bool IsNull() const { return m_tx_hash.IsNull(); }
      73             : 
      74             : public:
      75           0 :     SERIALIZE_METHODS(CSpentIndexValue, obj)
      76             :     {
      77           0 :         READWRITE(obj.m_tx_hash, obj.m_tx_index, obj.m_block_height, obj.m_amount, obj.m_address_type, obj.m_address_bytes);
      78           0 :     }
      79             : };
      80             : 
      81             : struct CSpentIndexKeyCompare {
      82           0 :     bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const
      83             :     {
      84           0 :         auto to_tuple = [](const CSpentIndexKey& obj) { return std::tie(obj.m_tx_hash, obj.m_tx_index); };
      85           0 :         return to_tuple(a) < to_tuple(b);
      86             :     }
      87             : };
      88             : 
      89             : using CSpentIndexEntry = std::pair<CSpentIndexKey, CSpentIndexValue>;
      90             : 
      91             : #endif // BITCOIN_INDEX_SPENTINDEX_TYPES_H

Generated by: LCOV version 1.16