LCOV - code coverage report
Current view: top level - src/budget - finalizedbudgetvote.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 17 25 68.0 %
Date: 2025-02-23 09:33:43 Functions: 4 6 66.7 %

          Line data    Source code
       1             : // Copyright (c) 2014-2015 The Dash developers
       2             : // Copyright (c) 2015-2021 The PIVX Core developers
       3             : // Distributed under the MIT/X11 software license, see the accompanying
       4             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5             : 
       6             : #include "budget/finalizedbudgetvote.h"
       7             : 
       8             : #include "net.h"
       9             : 
      10          79 : CFinalizedBudgetVote::CFinalizedBudgetVote() :
      11             :         CSignedMessage(),
      12             :         fValid(true),
      13             :         fSynced(false),
      14             :         vin(),
      15             :         nBudgetHash(),
      16          79 :         nTime(0)
      17          79 : { }
      18             : 
      19          22 : CFinalizedBudgetVote::CFinalizedBudgetVote(const CTxIn& vinIn, const uint256& nBudgetHashIn) :
      20             :         CSignedMessage(),
      21             :         fValid(true),
      22             :         fSynced(false),
      23             :         vin(vinIn),
      24          22 :         nBudgetHash(nBudgetHashIn)
      25             : {
      26          22 :     nTime = GetAdjustedTime();
      27          22 : }
      28             : 
      29          30 : void CFinalizedBudgetVote::Relay() const
      30             : {
      31          30 :     CInv inv(MSG_BUDGET_FINALIZED_VOTE, GetHash());
      32          30 :     g_connman->RelayInv(inv);
      33          30 : }
      34             : 
      35         555 : uint256 CFinalizedBudgetVote::GetHash() const
      36             : {
      37         555 :     CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
      38         555 :     ss << vin;
      39         555 :     ss << nBudgetHash;
      40         555 :     ss << nTime;
      41         555 :     return ss.GetHash();
      42             : }
      43             : 
      44           0 : UniValue CFinalizedBudgetVote::ToJSON() const
      45             : {
      46           0 :     UniValue bObj(UniValue::VOBJ);
      47           0 :     bObj.pushKV("nHash", GetHash().ToString());
      48           0 :     bObj.pushKV("nTime", (int64_t) nTime);
      49           0 :     bObj.pushKV("fValid", fValid);
      50           0 :     return bObj;
      51             : }
      52             : 
      53           0 : std::string CFinalizedBudgetVote::GetStrMessage() const
      54             : {
      55           0 :     return strprintf("%s %s %d", vin.prevout.ToStringShort(), nBudgetHash.ToString(), nTime);
      56             : }

Generated by: LCOV version 1.14