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 31 : CFinalizedBudgetVote::CFinalizedBudgetVote() : 11 : CSignedMessage(), 12 : fValid(true), 13 : fSynced(false), 14 : vin(), 15 : nBudgetHash(), 16 31 : nTime(0) 17 31 : { } 18 : 19 20 : CFinalizedBudgetVote::CFinalizedBudgetVote(const CTxIn& vinIn, const uint256& nBudgetHashIn) : 20 : CSignedMessage(), 21 : fValid(true), 22 : fSynced(false), 23 : vin(vinIn), 24 20 : nBudgetHash(nBudgetHashIn) 25 : { 26 20 : nTime = GetAdjustedTime(); 27 20 : } 28 : 29 11 : void CFinalizedBudgetVote::Relay() const 30 : { 31 11 : CInv inv(MSG_BUDGET_FINALIZED_VOTE, GetHash()); 32 11 : g_connman->RelayInv(inv); 33 11 : } 34 : 35 106 : uint256 CFinalizedBudgetVote::GetHash() const 36 : { 37 106 : CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); 38 106 : ss << vin; 39 106 : ss << nBudgetHash; 40 106 : ss << nTime; 41 106 : 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 : }