LCOV - code coverage report
Current view: top level - src/governance - common.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 16 17 94.1 %
Date: 2026-06-25 07:23:43 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2014-2025 The Dash Core developers
       2             : // Distributed under the MIT/X11 software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include <governance/common.h>
       6             : 
       7             : #include <util/strencodings.h>
       8             : #include <hash.h>
       9             : #include <univalue.h>
      10             : 
      11             : namespace Governance {
      12         616 : Object::Object(const uint256& nHashParent, int nRevision, int64_t nTime, const uint256& nCollateralHash, const std::string& strDataHex) :
      13             :     hashParent{nHashParent},
      14             :     revision{nRevision},
      15             :     time{nTime},
      16             :     collateralHash{nCollateralHash},
      17             :     masternodeOutpoint{},
      18             :     vchSig{},
      19             :     vchData{ParseHex(strDataHex)}
      20         308 : {
      21         308 : }
      22             : 
      23       43316 : uint256 Object::GetHash() const
      24             : {
      25             :     // Note: doesn't match serialization
      26             : 
      27             :     // CREATE HASH OF ALL IMPORTANT PIECES OF DATA
      28             : 
      29       43316 :     CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
      30       43316 :     ss << hashParent;
      31       43316 :     ss << revision;
      32       43316 :     ss << time;
      33       43316 :     ss << HexStr(vchData);
      34       43316 :     ss << masternodeOutpoint << uint8_t{} << 0xffffffff; // adding dummy values here to match old hashing
      35       43316 :     ss << vchSig;
      36             :     // fee_tx is left out on purpose
      37             : 
      38       43316 :     return ss.GetHash();
      39           0 : }
      40             : 
      41       25668 : std::string Object::GetDataAsHexString() const
      42             : {
      43       25668 :     return HexStr(vchData);
      44             : }
      45             : 
      46       20889 : std::string Object::GetDataAsPlainString() const
      47             : {
      48       20889 :     return std::string(vchData.begin(), vchData.end());
      49             : }
      50             : } // namespace Governance

Generated by: LCOV version 1.16