PRCYCoin  2.0.0.7rc1
P2P Digital Currency
masternode-budget.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2015 The Dash developers
2 // Copyright (c) 2015-2018 The PIVX developers
3 // Copyright (c) 2018-2020 The DAPS Project developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef MASTERNODE_BUDGET_H
8 #define MASTERNODE_BUDGET_H
9 
10 #include "base58.h"
11 #include "init.h"
12 #include "key.h"
13 #include "main.h"
14 #include "masternode.h"
15 #include "net.h"
16 #include "sync.h"
17 #include "util.h"
18 
19 
21 
22 class CBudgetManager;
24 class CFinalizedBudget;
25 class CBudgetProposal;
27 class CTxBudgetPayment;
28 
29 #define VOTE_ABSTAIN 0
30 #define VOTE_YES 1
31 #define VOTE_NO 2
32 
33 static const CAmount PROPOSAL_FEE_TX = (50 * COIN);
34 static const CAmount BUDGET_FEE_TX = (50 * COIN);
35 static const int64_t BUDGET_VOTE_UPDATE_MIN = 60 * 60;
36 
37 extern std::vector<CBudgetProposalBroadcast> vecImmatureBudgetProposals;
38 extern std::vector<CFinalizedBudgetBroadcast> vecImmatureFinalizedBudgets;
39 
40 extern CBudgetManager budget;
41 void DumpBudgets();
42 
43 // Define amount of blocks in budget payment cycle
45 
46 //Check the collateral transaction for the budget proposal/finalized budget
47 bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf);
48 
49 //
50 // CBudgetVote - Allow a masternode node to vote and broadcast throughout the network
51 //
52 
54 {
55 public:
56  bool fValid; //if the vote is currently valid / counted
57  bool fSynced; //if we've sent this to our peers
60  int nVote;
61  int64_t nTime;
62  std::vector<unsigned char> vchSig;
63 
64  CBudgetVote();
65  CBudgetVote(CTxIn vin, uint256 nProposalHash, int nVoteIn);
66 
67  bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
68  bool SignatureValid(bool fSignatureCheck);
69  void Relay();
70 
71  std::string GetVoteString()
72  {
73  std::string ret = "ABSTAIN";
74  if (nVote == VOTE_YES) ret = "YES";
75  if (nVote == VOTE_NO) ret = "NO";
76  return ret;
77  }
78 
80  {
81  CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
82  ss << vin;
83  ss << nProposalHash;
84  ss << nVote;
85  ss << nTime;
86  return ss.GetHash();
87  }
88 
90 
91  template <typename Stream, typename Operation>
92  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
93  {
94  READWRITE(vin);
99  }
100 };
101 
102 //
103 // CFinalizedBudgetVote - Allow a masternode node to vote and broadcast throughout the network
104 //
105 
107 {
108 public:
109  bool fValid; //if the vote is currently valid / counted
110  bool fSynced; //if we've sent this to our peers
113  int64_t nTime;
114  std::vector<unsigned char> vchSig;
115 
117  CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn);
118 
119  bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
120  bool SignatureValid(bool fSignatureCheck);
121  void Relay();
122 
124  {
125  CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
126  ss << vin;
127  ss << nBudgetHash;
128  ss << nTime;
129  return ss.GetHash();
130  }
131 
133 
134  template <typename Stream, typename Operation>
135  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
136  {
137  READWRITE(vin);
139  READWRITE(nTime);
140  READWRITE(vchSig);
141  }
142 };
143 
147 {
148 private:
149  fs::path pathDB;
150  std::string strMagicMessage;
151 
152 public:
153  enum ReadResult {
154  Ok,
161  };
162 
163  CBudgetDB();
164  bool Write(const CBudgetManager& objToSave);
165  ReadResult Read(CBudgetManager& objToLoad, bool fDryRun = false);
166 };
167 
168 
169 //
170 // Budget Manager : Contains all proposals for the budget
171 //
173 {
174 private:
175  //hold txes until they mature enough to use
176  // XX42 std::map<uint256, CTransaction> mapCollateral;
177  std::map<uint256, uint256> mapCollateralTxids;
178 
179 public:
180  // critical section to protect the inner data structures
182 
183  // keep track of the scanning errors I've seen
184  std::map<uint256, CBudgetProposal> mapProposals;
185  std::map<uint256, CFinalizedBudget> mapFinalizedBudgets;
186 
187  std::map<uint256, CBudgetProposalBroadcast> mapSeenMasternodeBudgetProposals;
188  std::map<uint256, CBudgetVote> mapSeenMasternodeBudgetVotes;
189  std::map<uint256, CBudgetVote> mapOrphanMasternodeBudgetVotes;
190  std::map<uint256, CFinalizedBudgetBroadcast> mapSeenFinalizedBudgets;
191  std::map<uint256, CFinalizedBudgetVote> mapSeenFinalizedBudgetVotes;
192  std::map<uint256, CFinalizedBudgetVote> mapOrphanFinalizedBudgetVotes;
193 
195  {
196  mapProposals.clear();
197  mapFinalizedBudgets.clear();
198  }
199 
200  void ClearSeen()
201  {
204  mapSeenFinalizedBudgets.clear();
206  }
207 
208  int sizeFinalized() { return (int)mapFinalizedBudgets.size(); }
209  int sizeProposals() { return (int)mapProposals.size(); }
210 
211  void ResetSync();
212  void MarkSynced();
213  void Sync(CNode* node, uint256 nProp, bool fPartial = false);
214 
215  void Calculate();
216  void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
217  void NewBlock();
218  CBudgetProposal* FindProposal(const std::string& strProposalName);
221  std::pair<std::string, std::string> GetVotes(std::string strProposalName);
222 
223  CAmount GetTotalBudget(int nHeight);
224  std::vector<CBudgetProposal*> GetBudget();
225  std::vector<CBudgetProposal*> GetAllProposals();
226  std::vector<CFinalizedBudget*> GetFinalizedBudgets();
227  bool IsBudgetPaymentBlock(int nBlockHeight);
228  bool AddProposal(CBudgetProposal& budgetProposal);
229  bool AddFinalizedBudget(CFinalizedBudget& finalizedBudget);
230  void SubmitFinalBudget();
231 
232  bool UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError);
233  bool UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError);
234  bool PropExists(uint256 nHash);
235  bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
236  std::string GetRequiredPaymentsString(int nBlockHeight);
237  bool FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake);
238 
239  void CheckOrphanVotes();
240  void Clear()
241  {
242  LOCK(cs);
243 
244  LogPrintf("Budget object cleared\n");
245  mapProposals.clear();
246  mapFinalizedBudgets.clear();
249  mapSeenFinalizedBudgets.clear();
253  }
254  void CheckAndRemove();
255  std::string ToString() const;
256 
257 
259 
260  template <typename Stream, typename Operation>
261  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
262  {
269 
272  }
273 };
274 
275 
277 {
278 public:
282 
284  {
285  payee = CScript();
286  nAmount = 0;
288  }
289 
291 
292  //for saving to the serialized db
293  template <typename Stream, typename Operation>
294  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
295  {
296  READWRITE(*(CScriptBase*)(&payee));
299  }
300 };
301 
302 //
303 // Finalized Budget : Contains the suggested proposals to pay on a given block
304 //
305 
307 {
308 private:
309  // critical section to protect the inner data structures
311  bool fAutoChecked; //If it matches what we see, we'll auto vote for it (masternode only)
312 
313 public:
314  bool fValid;
315  std::string strBudgetName;
317  std::vector<CTxBudgetPayment> vecBudgetPayments;
318  std::map<uint256, CFinalizedBudgetVote> mapVotes;
320  int64_t nTime;
321 
323  CFinalizedBudget(const CFinalizedBudget& other);
324 
325  void CleanAndRemove(bool fSignatureCheck);
326  bool AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError);
327  double GetScore();
329 
330  bool IsValid(std::string& strError, bool fCheckCollateral = true);
331 
332  std::string GetName() { return strBudgetName; }
333  std::string GetProposals();
334  int GetBlockStart() { return nBlockStart; }
335  int GetBlockEnd() { return nBlockStart + (int)(vecBudgetPayments.size() - 1); }
336  int GetVoteCount() { return (int)mapVotes.size(); }
337  bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
338  bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment)
339  {
340  LOCK(cs);
341 
342  int i = nBlockHeight - GetBlockStart();
343  if (i < 0) return false;
344  if (i > (int)vecBudgetPayments.size() - 1) return false;
345  payment = vecBudgetPayments[i];
346  return true;
347  }
348  bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount)
349  {
350  LOCK(cs);
351 
352  int i = nBlockHeight - GetBlockStart();
353  if (i < 0) return false;
354  if (i > (int)vecBudgetPayments.size() - 1) return false;
355  payee = vecBudgetPayments[i].payee;
356  nAmount = vecBudgetPayments[i].nAmount;
357  return true;
358  }
359 
360  //check to see if we should vote on this
361  void AutoCheck();
362  //total prcycoin paid out by this budget
364  //vote on this finalized budget as a masternode
365  void SubmitVote();
366 
367  //checks the hashes to make sure we know about them
368  std::string GetStatus();
369 
371  {
372  CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
373  ss << strBudgetName;
374  ss << nBlockStart;
375  ss << vecBudgetPayments;
376 
377  uint256 h1 = ss.GetHash();
378  return h1;
379  }
380 
382 
383  //for saving to the serialized db
384  template <typename Stream, typename Operation>
385  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
386  {
389  READWRITE(nTime);
393 
395  }
396 };
397 
398 // FinalizedBudget are cast then sent to peers with this object, which leaves the votes out
400 {
401 private:
402  std::vector<unsigned char> vchSig;
403 
404 public:
407  CFinalizedBudgetBroadcast(std::string strBudgetNameIn, int nBlockStartIn, std::vector<CTxBudgetPayment> vecBudgetPaymentsIn, uint256 nFeeTXHashIn);
408 
410  {
411  // enable ADL (not necessary in our case, but good practice)
412  using std::swap;
413 
414  // by swapping the members of two classes,
415  // the two classes are effectively swapped
416  swap(first.strBudgetName, second.strBudgetName);
417  swap(first.nBlockStart, second.nBlockStart);
418  first.mapVotes.swap(second.mapVotes);
419  first.vecBudgetPayments.swap(second.vecBudgetPayments);
420  swap(first.nFeeTXHash, second.nFeeTXHash);
421  swap(first.nTime, second.nTime);
422  }
423 
425  {
426  swap(*this, from);
427  return *this;
428  }
429 
430  void Relay();
431 
433 
434  //for propagating messages
435  template <typename Stream, typename Operation>
436  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
437  {
438  //for syncing with other clients
443  }
444 };
445 
446 
447 //
448 // Budget Proposal : Contains the masternode votes for each budget
449 //
450 
452 {
453 private:
454  // critical section to protect the inner data structures
457 
458 public:
459  bool fValid;
460  std::string strProposalName;
461 
462  /*
463  json object with name, short-description, long-description, pdf-url and any other info
464  This allows the proposal website to stay 100% decentralized
465  */
466  std::string strURL;
471  int64_t nTime;
473 
474  std::map<uint256, CBudgetVote> mapVotes;
475  //cache object
476 
477  CBudgetProposal();
478  CBudgetProposal(const CBudgetProposal& other);
479  CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn);
480 
481  void Calculate();
482  bool AddOrUpdateVote(CBudgetVote& vote, std::string& strError);
484  std::pair<std::string, std::string> GetVotes();
485 
486  bool IsValid(std::string& strError, bool fCheckCollateral = true);
487 
489  {
490  // Proposals must be at least a day old to make it into a budget
491  if (Params().NetworkID() == CBaseChainParams::MAIN) return (nTime < GetTime() - (60 * 60 * 24));
492 
493  // For testing purposes - 5 minutes
494  return (nTime < GetTime() - (60 * 5));
495  }
496 
497  std::string GetName() { return strProposalName; }
498  std::string GetURL() { return strURL; }
499  int GetBlockStart() { return nBlockStart; }
500  int GetBlockEnd() { return nBlockEnd; }
501  CScript GetPayee() { return address; }
502  int GetTotalPaymentCount();
504  int GetBlockStartCycle();
505  int GetBlockCurrentCycle();
506  int GetBlockEndCycle();
507  double GetRatio();
508  int GetYeas();
509  int GetNays();
510  int GetAbstains();
511  CAmount GetAmount() { return nAmount; }
512  void SetAllotted(CAmount nAllotedIn) { nAlloted = nAllotedIn; }
514 
515  void CleanAndRemove(bool fSignatureCheck);
516 
518  {
519  CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
520  ss << strProposalName;
521  ss << strURL;
522  ss << nBlockStart;
523  ss << nBlockEnd;
524  ss << nAmount;
525  ss << std::vector<unsigned char>(address.begin(), address.end());
526  uint256 h1 = ss.GetHash();
527 
528  return h1;
529  }
530 
532 
533  template <typename Stream, typename Operation>
534  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
535  {
536  //for syncing with other clients
539  READWRITE(nTime);
544  READWRITE(nTime);
546 
547  //for saving to the serialized db
549  }
550 };
551 
552 // Proposals are cast then sent to peers with this object, which leaves the votes out
554 {
555 public:
559  CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn);
560 
561  void swap(CBudgetProposalBroadcast& first, CBudgetProposalBroadcast& second) // nothrow
562  {
563  // enable ADL (not necessary in our case, but good practice)
564  using std::swap;
565 
566  // by swapping the members of two classes,
567  // the two classes are effectively swapped
568  swap(first.strProposalName, second.strProposalName);
569  swap(first.nBlockStart, second.nBlockStart);
570  swap(first.strURL, second.strURL);
571  swap(first.nBlockEnd, second.nBlockEnd);
572  swap(first.nAmount, second.nAmount);
573  swap(first.address, second.address);
574  swap(first.nTime, second.nTime);
575  swap(first.nFeeTXHash, second.nFeeTXHash);
576  first.mapVotes.swap(second.mapVotes);
577  }
578 
580  {
581  swap(*this, from);
582  return *this;
583  }
584 
585  void Relay();
586 
588 
589  template <typename Stream, typename Operation>
590  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
591  {
592  //for syncing with other clients
593 
596  READWRITE(nTime);
602  }
603 };
604 
605 
606 #endif
CTxBudgetPayment::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:294
vecImmatureBudgetProposals
std::vector< CBudgetProposalBroadcast > vecImmatureBudgetProposals
Definition: masternode-budget.cpp:23
CBudgetManager::PropExists
bool PropExists(uint256 nHash)
Definition: masternode-budget.cpp:1169
CTxIn
An input of a transaction.
Definition: transaction.h:83
CBudgetManager::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:258
CBudgetProposal::nFeeTXHash
uint256 nFeeTXHash
Definition: masternode-budget.h:472
CFinalizedBudget::HasMinimumRequiredSupport
bool HasMinimumRequiredSupport()
CBudgetManager::sizeFinalized
int sizeFinalized()
Definition: masternode-budget.h:208
UINT256_ZERO
const uint256 UINT256_ZERO
constant uint256 instances
Definition: uint256.h:129
CBudgetManager::mapSeenMasternodeBudgetProposals
std::map< uint256, CBudgetProposalBroadcast > mapSeenMasternodeBudgetProposals
Definition: masternode-budget.h:187
CBudgetVote::GetVoteString
std::string GetVoteString()
Definition: masternode-budget.h:71
CBudgetManager::GetFinalizedBudgets
std::vector< CFinalizedBudget * > GetFinalizedBudgets()
Definition: masternode-budget.cpp:780
CBudgetManager::FindFinalizedBudget
CFinalizedBudget * FindFinalizedBudget(uint256 nHash)
Definition: masternode-budget.cpp:554
CBudgetVote::Sign
bool Sign(CKey &keyMasternode, CPubKey &pubKeyMasternode)
Definition: masternode-budget.cpp:1684
DumpBudgets
void DumpBudgets()
Definition: masternode-budget.cpp:372
CFinalizedBudget::AddOrUpdateVote
bool AddOrUpdateVote(CFinalizedBudgetVote &vote, std::string &strError)
Definition: masternode-budget.cpp:1755
CFinalizedBudgetVote::SignatureValid
bool SignatureValid(bool fSignatureCheck)
Definition: masternode-budget.cpp:2143
CBudgetManager::ResetSync
void ResetSync()
Definition: masternode-budget.cpp:1176
GetTime
int64_t GetTime()
For unit testing.
Definition: utiltime.cpp:19
CBudgetProposal::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:531
SER_GETHASH
@ SER_GETHASH
Definition: serialize.h:161
CBudgetProposalBroadcast::CBudgetProposalBroadcast
CBudgetProposalBroadcast(const CBudgetProposal &other)
Definition: masternode-budget.h:557
CBudgetManager::mapOrphanMasternodeBudgetVotes
std::map< uint256, CBudgetVote > mapOrphanMasternodeBudgetVotes
Definition: masternode-budget.h:189
CBudgetDB::ReadResult
ReadResult
Definition: masternode-budget.h:153
CBudgetManager::mapSeenFinalizedBudgets
std::map< uint256, CFinalizedBudgetBroadcast > mapSeenFinalizedBudgets
Definition: masternode-budget.h:190
CBudgetProposal::nBlockEnd
int nBlockEnd
Definition: masternode-budget.h:468
CFinalizedBudget::nBlockStart
int nBlockStart
Definition: masternode-budget.h:316
CFinalizedBudget::vecBudgetPayments
std::vector< CTxBudgetPayment > vecBudgetPayments
Definition: masternode-budget.h:317
CBudgetProposalBroadcast::operator=
CBudgetProposalBroadcast & operator=(CBudgetProposalBroadcast from)
Definition: masternode-budget.h:579
CBudgetProposal::GetAmount
CAmount GetAmount()
Definition: masternode-budget.h:511
CBudgetProposal::Calculate
void Calculate()
VOTE_YES
#define VOTE_YES
Definition: masternode-budget.h:30
sync.h
CBudgetDB::IncorrectFormat
@ IncorrectFormat
Definition: masternode-budget.h:160
CBudgetManager::mapSeenMasternodeBudgetVotes
std::map< uint256, CBudgetVote > mapSeenMasternodeBudgetVotes
Definition: masternode-budget.h:188
CBudgetManager::GetAllProposals
std::vector< CBudgetProposal * > GetAllProposals()
Definition: masternode-budget.cpp:669
CBudgetProposal::GetBlockEnd
int GetBlockEnd()
Definition: masternode-budget.h:500
CFinalizedBudgetVote::fValid
bool fValid
Definition: masternode-budget.h:109
CFinalizedBudgetVote::vchSig
std::vector< unsigned char > vchSig
Definition: masternode-budget.h:114
CNode
Information about a peer.
Definition: net.h:306
CBudgetProposal::GetTotalPaymentCount
int GetTotalPaymentCount()
Definition: masternode-budget.cpp:1616
CBudgetProposal::strURL
std::string strURL
Definition: masternode-budget.h:466
CBudgetDB::IncorrectHash
@ IncorrectHash
Definition: masternode-budget.h:157
CFinalizedBudget::fValid
bool fValid
Definition: masternode-budget.h:314
CBudgetProposal::GetRatio
double GetRatio()
Definition: masternode-budget.cpp:1530
CBudgetProposal::address
CScript address
Definition: masternode-budget.h:470
CBudgetVote::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:89
CBudgetProposal::cs
RecursiveMutex cs
Definition: masternode-budget.h:455
AnnotatedMixin< std::recursive_mutex >
cs_budget
RecursiveMutex cs_budget
Definition: masternode-budget.cpp:20
CBudgetVote::CBudgetVote
CBudgetVote()
Definition: masternode-budget.cpp:1658
CBudgetDB::strMagicMessage
std::string strMagicMessage
Definition: masternode-budget.h:150
CFinalizedBudget::GetName
std::string GetName()
Definition: masternode-budget.h:332
CBudgetProposal::GetAbstains
int GetAbstains()
Definition: masternode-budget.cpp:1574
CBudgetVote::fSynced
bool fSynced
Definition: masternode-budget.h:57
CBudgetManager::UpdateProposal
bool UpdateProposal(CBudgetVote &vote, CNode *pfrom, std::string &strError)
Definition: masternode-budget.cpp:1320
CBudgetVote::Relay
void Relay()
Definition: masternode-budget.cpp:1678
CFinalizedBudget::GetProposals
std::string GetProposals()
Definition: masternode-budget.cpp:1888
CBudgetProposal::GetRemainingPaymentCount
int GetRemainingPaymentCount()
Definition: masternode-budget.cpp:1621
IsBudgetCollateralValid
bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string &strError, int64_t &nTime, int &nConf)
Definition: masternode-budget.cpp:37
CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast
CFinalizedBudgetBroadcast()
Definition: masternode-budget.cpp:2057
CFinalizedBudget::strBudgetName
std::string strBudgetName
Definition: masternode-budget.h:315
CBudgetManager::ToString
std::string ToString() const
Definition: masternode-budget.cpp:2166
CTxBudgetPayment::payee
CScript payee
Definition: masternode-budget.h:280
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:269
CFinalizedBudgetVote::Relay
void Relay()
Definition: masternode-budget.cpp:2113
CBudgetManager::mapProposals
std::map< uint256, CBudgetProposal > mapProposals
Definition: masternode-budget.h:184
CBudgetManager::UpdateFinalizedBudget
bool UpdateFinalizedBudget(CFinalizedBudgetVote &vote, CNode *pfrom, std::string &strError)
Definition: masternode-budget.cpp:1347
CBudgetVote
Definition: masternode-budget.h:53
CBudgetManager::Calculate
void Calculate()
CTxBudgetPayment::CTxBudgetPayment
CTxBudgetPayment()
Definition: masternode-budget.h:283
vecImmatureFinalizedBudgets
std::vector< CFinalizedBudgetBroadcast > vecImmatureFinalizedBudgets
Definition: masternode-budget.cpp:24
CBudgetProposalBroadcast::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:590
CBudgetVote::GetHash
uint256 GetHash()
Definition: masternode-budget.h:79
prevector::end
iterator end()
Definition: prevector.h:292
CBudgetManager::cs
RecursiveMutex cs
Definition: masternode-budget.h:181
CBudgetProposal::nTime
int64_t nTime
Definition: masternode-budget.h:471
CBudgetProposal::GetYeas
int GetYeas()
Definition: masternode-budget.cpp:1548
CBudgetManager::IsBudgetPaymentBlock
bool IsBudgetPaymentBlock(int nBlockHeight)
Definition: masternode-budget.cpp:593
CFinalizedBudgetBroadcast::operator=
CFinalizedBudgetBroadcast & operator=(CFinalizedBudgetBroadcast from)
Definition: masternode-budget.h:424
CFinalizedBudgetBroadcast::Relay
void Relay()
Definition: masternode-budget.cpp:2087
CBudgetDB::IncorrectMagicMessage
@ IncorrectMagicMessage
Definition: masternode-budget.h:158
CBudgetManager::GetBudget
std::vector< CBudgetProposal * > GetBudget()
Definition: masternode-budget.cpp:701
CBudgetProposal
Definition: masternode-budget.h:451
CBudgetManager::Sync
void Sync(CNode *node, uint256 nProp, bool fPartial=false)
Definition: masternode-budget.cpp:1250
CBudgetProposalBroadcast::swap
void swap(CBudgetProposalBroadcast &first, CBudgetProposalBroadcast &second)
Definition: masternode-budget.h:561
CBudgetProposal::GetVotes
std::pair< std::string, std::string > GetVotes()
CFinalizedBudgetVote::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:132
init.h
CBudgetProposalBroadcast::Relay
void Relay()
Definition: masternode-budget.cpp:1652
CBudgetManager::mapFinalizedBudgets
std::map< uint256, CFinalizedBudget > mapFinalizedBudgets
Definition: masternode-budget.h:185
CBudgetProposal::nBlockStart
int nBlockStart
Definition: masternode-budget.h:467
CBudgetProposal::AddOrUpdateVote
bool AddOrUpdateVote(CBudgetVote &vote, std::string &strError)
Definition: masternode-budget.cpp:1486
CBudgetVote::SignatureValid
bool SignatureValid(bool fSignatureCheck)
Definition: masternode-budget.cpp:1708
CBudgetManager::IsTransactionValid
bool IsTransactionValid(const CTransaction &txNew, int nBlockHeight)
Definition: masternode-budget.cpp:619
CFinalizedBudget::nFeeTXHash
uint256 nFeeTXHash
Definition: masternode-budget.h:319
CFinalizedBudget::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:381
CBudgetProposal::nAlloted
CAmount nAlloted
Definition: masternode-budget.h:456
CBaseChainParams::MAIN
@ MAIN
Definition: chainparamsbase.h:19
CFinalizedBudget::CFinalizedBudget
CFinalizedBudget()
Definition: masternode-budget.cpp:1731
LogPrintf
#define LogPrintf(...)
Definition: logging.h:147
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CFinalizedBudget::GetTotalPayout
CAmount GetTotalPayout()
Definition: masternode-budget.cpp:1877
CBudgetProposal::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:534
CFinalizedBudgetVote::Sign
bool Sign(CKey &keyMasternode, CPubKey &pubKeyMasternode)
Definition: masternode-budget.cpp:2119
CBudgetDB::HashReadError
@ HashReadError
Definition: masternode-budget.h:156
CTxBudgetPayment::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:290
CFinalizedBudget::GetScore
double GetScore()
CFinalizedBudget::GetBudgetPaymentByBlock
bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment &payment)
Definition: masternode-budget.h:338
CTxBudgetPayment::nProposalHash
uint256 nProposalHash
Definition: masternode-budget.h:279
CBudgetManager::FillBlockPayee
bool FillBlockPayee(CMutableTransaction &txNew, CAmount nFees, bool fProofOfStake)
Definition: masternode-budget.cpp:490
CFinalizedBudgetBroadcast
Definition: masternode-budget.h:399
CBudgetManager::sizeProposals
int sizeProposals()
Definition: masternode-budget.h:209
CFinalizedBudget::GetBlockEnd
int GetBlockEnd()
Definition: masternode-budget.h:335
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
CFinalizedBudgetVote::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:135
CBudgetManager::FindProposal
CBudgetProposal * FindProposal(const std::string &strProposalName)
Definition: masternode-budget.cpp:562
CBudgetManager::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:261
CBudgetVote::nTime
int64_t nTime
Definition: masternode-budget.h:61
CBudgetManager::SubmitFinalBudget
void SubmitFinalBudget()
Definition: masternode-budget.cpp:125
VOTE_NO
#define VOTE_NO
Definition: masternode-budget.h:31
CFinalizedBudget
Definition: masternode-budget.h:306
CFinalizedBudgetVote
Definition: masternode-budget.h:106
CBudgetManager::mapCollateralTxids
std::map< uint256, uint256 > mapCollateralTxids
Definition: masternode-budget.h:177
CFinalizedBudget::GetPayeeAndAmount
bool GetPayeeAndAmount(int64_t nBlockHeight, CScript &payee, CAmount &nAmount)
Definition: masternode-budget.h:348
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:363
CBudgetDB::CBudgetDB
CBudgetDB()
Definition: masternode-budget.cpp:248
CBudgetProposal::GetBlockCurrentCycle
int GetBlockCurrentCycle()
Definition: masternode-budget.cpp:1594
CTxBudgetPayment::nAmount
CAmount nAmount
Definition: masternode-budget.h:281
CBudgetManager::GetRequiredPaymentsString
std::string GetRequiredPaymentsString(int nBlockHeight)
Definition: masternode-budget.cpp:807
CFinalizedBudget::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:385
CBudgetProposal::IsEstablished
bool IsEstablished()
Definition: masternode-budget.h:488
CBudgetProposal::CBudgetProposal
CBudgetProposal()
Definition: masternode-budget.cpp:1373
CBudgetProposal::SetAllotted
void SetAllotted(CAmount nAllotedIn)
Definition: masternode-budget.h:512
CBudgetVote::vchSig
std::vector< unsigned char > vchSig
Definition: masternode-budget.h:62
CBudgetManager
Definition: masternode-budget.h:172
CFinalizedBudget::AutoCheck
void AutoCheck()
Definition: masternode-budget.cpp:1788
CFinalizedBudgetVote::CFinalizedBudgetVote
CFinalizedBudgetVote()
Definition: masternode-budget.cpp:2093
CBudgetVote::nProposalHash
uint256 nProposalHash
Definition: masternode-budget.h:59
prevector
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:36
CBudgetProposalBroadcast::CBudgetProposalBroadcast
CBudgetProposalBroadcast(const CBudgetProposalBroadcast &other)
Definition: masternode-budget.h:558
key.h
CFinalizedBudget::GetHash
uint256 GetHash()
Definition: masternode-budget.h:370
CBudgetDB::pathDB
fs::path pathDB
Definition: masternode-budget.h:149
CPubKey
An encapsulated public key.
Definition: pubkey.h:37
CBudgetManager::ProcessMessage
void ProcessMessage(CNode *pfrom, std::string &strCommand, CDataStream &vRecv)
Definition: masternode-budget.cpp:988
CBudgetManager::ClearSeen
void ClearSeen()
Definition: masternode-budget.h:200
CBudgetProposal::IsValid
bool IsValid(std::string &strError, bool fCheckCollateral=true)
Definition: masternode-budget.cpp:1409
READWRITE
#define READWRITE(obj)
Definition: serialize.h:164
budget
CBudgetManager budget
Definition: masternode-budget.cpp:19
CFinalizedBudgetBroadcast::vchSig
std::vector< unsigned char > vchSig
Definition: masternode-budget.h:402
CKey
An encapsulated private key.
Definition: key.h:39
CTxBudgetPayment
Definition: masternode-budget.h:276
CBudgetManager::AddProposal
bool AddProposal(CBudgetProposal &budgetProposal)
Definition: masternode-budget.cpp:412
main.h
CFinalizedBudget::CleanAndRemove
void CleanAndRemove(bool fSignatureCheck)
Definition: masternode-budget.cpp:1866
LOCK
#define LOCK(cs)
Definition: sync.h:182
CBudgetProposal::nAmount
CAmount nAmount
Definition: masternode-budget.h:469
CBudgetDB::Ok
@ Ok
Definition: masternode-budget.h:154
CBudgetProposal::GetNays
int GetNays()
Definition: masternode-budget.cpp:1561
CFinalizedBudgetVote::vin
CTxIn vin
Definition: masternode-budget.h:111
CBudgetProposalBroadcast
Definition: masternode-budget.h:553
CBudgetManager::CBudgetManager
CBudgetManager()
Definition: masternode-budget.h:194
CFinalizedBudget::IsValid
bool IsValid(std::string &strError, bool fCheckCollateral=true)
Definition: masternode-budget.cpp:1943
CHashWriter
A writer stream (for serialization) that computes a 256-bit hash.
Definition: hash.h:259
prevector::begin
iterator begin()
Definition: prevector.h:290
CBudgetDB::FileError
@ FileError
Definition: masternode-budget.h:155
CFinalizedBudget::IsTransactionValid
bool IsTransactionValid(const CTransaction &txNew, int nBlockHeight)
Definition: masternode-budget.cpp:1996
masternode.h
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:463
CBudgetManager::GetVotes
std::pair< std::string, std::string > GetVotes(std::string strProposalName)
CFinalizedBudgetVote::nTime
int64_t nTime
Definition: masternode-budget.h:113
CBudgetDB::IncorrectMagicNumber
@ IncorrectMagicNumber
Definition: masternode-budget.h:159
CFinalizedBudget::SubmitVote
void SubmitVote()
Definition: masternode-budget.cpp:2030
CBudgetManager::AddFinalizedBudget
bool AddFinalizedBudget(CFinalizedBudget &finalizedBudget)
Definition: masternode-budget.cpp:399
CBudgetDB::Write
bool Write(const CBudgetManager &objToSave)
Definition: masternode-budget.cpp:254
CFinalizedBudget::GetStatus
std::string GetStatus()
Definition: masternode-budget.cpp:1908
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:34
CBudgetProposal::HasMinimumRequiredSupport
bool HasMinimumRequiredSupport()
CBudgetVote::fValid
bool fValid
Definition: masternode-budget.h:56
CBudgetProposal::GetBlockEndCycle
int GetBlockEndCycle()
Definition: masternode-budget.cpp:1604
base58.h
CBudgetProposal::GetURL
std::string GetURL()
Definition: masternode-budget.h:498
CBudgetProposal::GetBlockStart
int GetBlockStart()
Definition: masternode-budget.h:499
CBudgetManager::MarkSynced
void MarkSynced()
Definition: masternode-budget.cpp:1210
CBudgetProposal::GetHash
uint256 GetHash()
Definition: masternode-budget.h:517
GetBudgetPaymentCycleBlocks
int GetBudgetPaymentCycleBlocks()
Definition: masternode-budget.cpp:28
CBudgetDB::Read
ReadResult Read(CBudgetManager &objToLoad, bool fDryRun=false)
Definition: masternode-budget.cpp:287
CBudgetProposal::GetName
std::string GetName()
Definition: masternode-budget.h:497
CBudgetProposal::mapVotes
std::map< uint256, CBudgetVote > mapVotes
Definition: masternode-budget.h:474
CBudgetManager::CheckAndRemove
void CheckAndRemove()
Definition: masternode-budget.cpp:430
CFinalizedBudget::mapVotes
std::map< uint256, CFinalizedBudgetVote > mapVotes
Definition: masternode-budget.h:318
CFinalizedBudget::cs
RecursiveMutex cs
Definition: masternode-budget.h:310
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:384
CHashWriter::GetHash
uint256 GetHash()
Definition: hash.h:277
CBudgetManager::NewBlock
void NewBlock()
Definition: masternode-budget.cpp:876
CBudgetManager::mapSeenFinalizedBudgetVotes
std::map< uint256, CFinalizedBudgetVote > mapSeenFinalizedBudgetVotes
Definition: masternode-budget.h:191
net.h
CBudgetProposal::fValid
bool fValid
Definition: masternode-budget.h:459
CFinalizedBudgetBroadcast::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:436
CBudgetManager::mapOrphanFinalizedBudgetVotes
std::map< uint256, CFinalizedBudgetVote > mapOrphanFinalizedBudgetVotes
Definition: masternode-budget.h:192
CFinalizedBudget::GetVoteCount
int GetVoteCount()
Definition: masternode-budget.h:336
CBudgetManager::Clear
void Clear()
Definition: masternode-budget.h:240
CFinalizedBudgetVote::fSynced
bool fSynced
Definition: masternode-budget.h:110
CBudgetVote::vin
CTxIn vin
Definition: masternode-budget.h:58
util.h
CBudgetVote::nVote
int nVote
Definition: masternode-budget.h:60
LIMITED_STRING
#define LIMITED_STRING(obj, n)
Definition: serialize.h:367
CBudgetProposal::GetBlockStartCycle
int GetBlockStartCycle()
Definition: masternode-budget.cpp:1587
CFinalizedBudgetVote::nBudgetHash
uint256 nBudgetHash
Definition: masternode-budget.h:112
CBudgetManager::GetTotalBudget
CAmount GetTotalBudget(int nHeight)
Definition: masternode-budget.cpp:836
CBudgetProposal::GetAllotted
CAmount GetAllotted()
Definition: masternode-budget.h:513
CBudgetDB
Save Budget Manager (budget.dat)
Definition: masternode-budget.h:146
CBudgetVote::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: masternode-budget.h:92
CBudgetProposal::CleanAndRemove
void CleanAndRemove(bool fSignatureCheck)
Definition: masternode-budget.cpp:1520
CBudgetManager::CheckOrphanVotes
void CheckOrphanVotes()
Definition: masternode-budget.cpp:98
CFinalizedBudget::nTime
int64_t nTime
Definition: masternode-budget.h:320
CBudgetProposalBroadcast::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:587
CFinalizedBudgetBroadcast::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: masternode-budget.h:432
CFinalizedBudgetBroadcast::swap
void swap(CFinalizedBudgetBroadcast &first, CFinalizedBudgetBroadcast &second)
Definition: masternode-budget.h:409
CBudgetProposalBroadcast::CBudgetProposalBroadcast
CBudgetProposalBroadcast()
Definition: masternode-budget.h:556
CFinalizedBudget::fAutoChecked
bool fAutoChecked
Definition: masternode-budget.h:311
CFinalizedBudgetVote::GetHash
uint256 GetHash()
Definition: masternode-budget.h:123
CFinalizedBudget::GetBlockStart
int GetBlockStart()
Definition: masternode-budget.h:334
CBudgetProposal::GetPayee
CScript GetPayee()
Definition: masternode-budget.h:501
CBudgetProposal::strProposalName
std::string strProposalName
Definition: masternode-budget.h:460