Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

governance-classes.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2020 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 #ifndef GOVERNANCE_CLASSES_H
5 #define GOVERNANCE_CLASSES_H
6 
7 #include <base58.h>
9 #include <key.h>
10 #include <script/standard.h>
11 #include <util.h>
12 
13 class CSuperblock;
16 
17 typedef std::shared_ptr<CSuperblock> CSuperblock_sptr;
18 
19 // DECLARE GLOBAL VARIABLES FOR GOVERNANCE CLASSES
21 
30 {
31  friend class CSuperblockManager;
32  friend class CGovernanceManager;
33 
34 private:
35  typedef std::map<uint256, CSuperblock_sptr> trigger_m_t;
36  typedef trigger_m_t::iterator trigger_m_it;
37 
39 
40  std::vector<CSuperblock_sptr> GetActiveTriggers();
41  bool AddNewTrigger(uint256 nHash);
42  void CleanAndRemove();
43 
44 public:
46  mapTrigger() {}
47 };
48 
56 {
57 private:
58  static bool GetBestSuperblock(CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
59 
60 public:
61  static bool IsSuperblockTriggered(int nBlockHeight);
62 
63  static bool GetSuperblockPayments(int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet);
64  static void ExecuteBestSuperblock(int nBlockHeight);
65 
66  static std::string GetRequiredPaymentsString(int nBlockHeight);
67  static bool IsValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward);
68 };
69 
76 {
77 private:
78  bool fValid;
79 
80 public:
83 
85  fValid(false),
86  script(),
87  nAmount(0)
88  {
89  }
90 
92  fValid(false),
93  script(),
94  nAmount(0)
95  {
96  try {
97  CTxDestination dest = destIn;
99  nAmount = nAmountIn;
100  fValid = true;
101  } catch (std::exception& e) {
102  LogPrintf("CGovernancePayment Payment not valid: destIn = %s, nAmountIn = %d, what = %s\n",
103  EncodeDestination(destIn), nAmountIn, e.what());
104  } catch (...) {
105  LogPrintf("CGovernancePayment Payment not valid: destIn = %s, nAmountIn = %d\n",
106  EncodeDestination(destIn), nAmountIn);
107  }
108  }
109 
110  bool IsValid() { return fValid; }
111 };
112 
113 
132 {
133 private:
135 
137  int nStatus;
138  std::vector<CGovernancePayment> vecPayments;
139 
140  void ParsePaymentSchedule(const std::string& strPaymentAddresses, const std::string& strPaymentAmounts);
141 
142 public:
143  CSuperblock();
144  explicit CSuperblock(uint256& nHash);
145 
146  static bool IsValidBlockHeight(int nBlockHeight);
147  static void GetNearestSuperblocksHeights(int nBlockHeight, int& nLastSuperblockRet, int& nNextSuperblockRet);
149 
150  int GetStatus() { return nStatus; }
151  void SetStatus(int nStatusIn) { nStatus = nStatusIn; }
152 
153  // TELL THE ENGINE WE EXECUTED THIS EVENT
155 
157  {
160  return pObj;
161  }
162 
164  {
165  return nBlockHeight;
166  }
167 
168  int CountPayments() { return (int)vecPayments.size(); }
169  bool GetPayment(int nPaymentIndex, CGovernancePayment& paymentRet);
171 
172  bool IsValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward);
173  bool IsExpired() const;
174 };
175 
176 #endif
std::vector< CSuperblock_sptr > GetActiveTriggers()
Get Active Triggers.
CGovernancePayment(CTxDestination destIn, CAmount nAmountIn)
Superblock Manager.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:80
Governance Object.
static void GetNearestSuperblocksHeights(int nBlockHeight, int &nLastSuperblockRet, int &nNextSuperblockRet)
static bool IsSuperblockTriggered(int nBlockHeight)
Is Superblock Triggered.
Trigger : Superblock.
CGovernanceObject * GetGovernanceObject()
static bool IsValid(const CTransaction &txNew, int nBlockHeight, CAmount blockReward)
trigger_m_t::iterator trigger_m_it
CGovernanceObject * FindGovernanceObject(const uint256 &nHash)
Definition: governance.cpp:463
bool AddNewTrigger(uint256 nHash)
Add Governance Object.
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
CGovernanceManager governance
Definition: governance.cpp:23
false
Definition: bls_dkg.cpp:168
void SetStatus(int nStatusIn)
std::shared_ptr< CSuperblock > CSuperblock_sptr
#define LogPrintf(...)
Definition: util.h:203
static bool IsValidBlockHeight(int nBlockHeight)
Is Valid Superblock Height.
CGovernanceTriggerManager triggerman
void CleanAndRemove()
Clean And Remove.
static std::string GetRequiredPaymentsString(int nBlockHeight)
Get Required Payment String.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:256
std::map< uint256, CSuperblock_sptr > trigger_m_t
static const int SEEN_OBJECT_EXECUTED
256-bit opaque blob.
Definition: uint256.h:123
static bool GetSuperblockPayments(int nBlockHeight, std::vector< CTxOut > &voutSuperblockRet)
Get Superblock Payments.
Governance Object Payment.
static CAmount GetPaymentsLimit(int nBlockHeight)
std::string EncodeDestination(const CTxDestination &dest)
Definition: base58.cpp:329
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:389
static bool GetBestSuperblock(CSuperblock_sptr &pSuperblockRet, int nBlockHeight)
CAmount GetPaymentsTotalAmount()
CCriticalSection cs
Definition: governance.h:278
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
void ParsePaymentSchedule(const std::string &strPaymentAddresses, const std::string &strPaymentAmounts)
AssertLockHeld(g_cs_orphans)
static void ExecuteBestSuperblock(int nBlockHeight)
std::vector< CGovernancePayment > vecPayments
bool IsValid(const CTransaction &txNew, int nBlockHeight, CAmount blockReward)
Is Transaction Valid.
bool GetPayment(int nPaymentIndex, CGovernancePayment &paymentRet)
bool IsExpired() const
Released under the MIT license