Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

simplifiedmns.h
Go to the documentation of this file.
1 // Copyright (c) 2017-2020 The Dash Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef DASH_SIMPLIFIEDMNS_H
6 #define DASH_SIMPLIFIEDMNS_H
7 
8 #include <bls/bls.h>
9 #include <merkleblock.h>
10 #include <netaddress.h>
11 #include <pubkey.h>
12 #include <serialize.h>
13 #include <version.h>
14 
15 class UniValue;
17 class CDeterministicMN;
18 
19 namespace llmq
20 {
21  class CFinalCommitment;
22 } // namespace llmq
23 
25 {
26 public:
32  bool isValid;
33 
34 public:
36  explicit CSimplifiedMNListEntry(const CDeterministicMN& dmn);
37 
38  bool operator==(const CSimplifiedMNListEntry& rhs) const
39  {
40  return proRegTxHash == rhs.proRegTxHash &&
42  service == rhs.service &&
44  keyIDVoting == rhs.keyIDVoting &&
45  isValid == rhs.isValid;
46  }
47 
48  bool operator!=(const CSimplifiedMNListEntry& rhs) const
49  {
50  return !(rhs == *this);
51  }
52 
53 public:
55 
56  template <typename Stream, typename Operation>
57  inline void SerializationOp(Stream& s, Operation ser_action)
58  {
65  }
66 
67 public:
68  uint256 CalcHash() const;
69 
70  std::string ToString() const;
71  void ToJson(UniValue& obj) const;
72 };
73 
75 {
76 public:
77  std::vector<std::unique_ptr<CSimplifiedMNListEntry>> mnList;
78 
79 public:
81  explicit CSimplifiedMNList(const std::vector<CSimplifiedMNListEntry>& smlEntries);
82  explicit CSimplifiedMNList(const CDeterministicMNList& dmnList);
83 
84  uint256 CalcMerkleRoot(bool* pmutated = nullptr) const;
85 };
86 
88 
90 {
91 public:
94 
95 public:
97 
98  template <typename Stream, typename Operation>
99  inline void SerializationOp(Stream& s, Operation ser_action)
100  {
103  }
104 };
105 
107 {
108 public:
113  std::vector<uint256> deletedMNs;
114  std::vector<CSimplifiedMNListEntry> mnList;
115 
116  // starting with proto version LLMQS_PROTO_VERSION, we also transfer changes in active quorums
117  std::vector<std::pair<uint8_t, uint256>> deletedQuorums; // p<LLMQType, quorumHash>
118  std::vector<llmq::CFinalCommitment> newQuorums;
119 
120 public:
122 
123  template <typename Stream, typename Operation>
124  inline void SerializationOp(Stream& s, Operation ser_action)
125  {
129  READWRITE(cbTx);
131  READWRITE(mnList);
132 
133  if (s.GetVersion() >= LLMQS_PROTO_VERSION) {
136  }
137  }
138 
139 public:
142 
143  bool BuildQuorumsDiff(const CBlockIndex* baseBlockIndex, const CBlockIndex* blockIndex);
144 
145  void ToJson(UniValue& obj) const;
146 };
147 
148 bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet);
149 
150 #endif //DASH_SIMPLIFIEDMNS_H
CKeyID keyIDVoting
Definition: simplifiedmns.h:31
uint256 confirmedHash
Definition: simplifiedmns.h:28
std::vector< llmq::CFinalCommitment > newQuorums
void SerializationOp(Stream &s, Operation ser_action)
void ToJson(UniValue &obj) const
#define READWRITE(obj)
Definition: serialize.h:165
bool operator==(const CSimplifiedMNListEntry &rhs) const
Definition: simplifiedmns.h:38
Data structure that represents a partial merkle tree.
Definition: merkleblock.h:50
uint256 proRegTxHash
Definition: simplifiedmns.h:27
CTransactionRef cbTx
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:345
Definition: simplifiedmns.h:24
void SerializationOp(Stream &s, Operation ser_action)
Definition: simplifiedmns.h:57
bool BuildQuorumsDiff(const CBlockIndex *baseBlockIndex, const CBlockIndex *blockIndex)
bool operator!=(const CSimplifiedMNListEntry &rhs) const
Definition: simplifiedmns.h:48
static const int LLMQS_PROTO_VERSION
introduction of LLMQs
Definition: version.h:51
uint256 CalcHash() const
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:143
CBLSLazyPublicKey pubKeyOperator
Definition: simplifiedmns.h:30
std::string ToString() const
bool BuildSimplifiedMNListDiff(const uint256 &baseBlockHash, const uint256 &blockHash, CSimplifiedMNListDiff &mnListDiffRet, std::string &errorRet)
bool isValid
Definition: simplifiedmns.h:32
256-bit opaque blob.
Definition: uint256.h:123
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:20
ADD_SERIALIZE_METHODS
Definition: simplifiedmns.h:54
CPartialMerkleTree cbTxMerkleTree
uint256 CalcMerkleRoot(bool *pmutated=nullptr) const
std::vector< std::unique_ptr< CSimplifiedMNListEntry > > mnList
Definition: simplifiedmns.h:77
void SerializationOp(Stream &s, Operation ser_action)
Definition: simplifiedmns.h:99
void ToJson(UniValue &obj) const
std::vector< uint256 > deletedMNs
std::vector< CSimplifiedMNListEntry > mnList
CService service
Definition: simplifiedmns.h:29
std::vector< std::pair< uint8_t, uint256 > > deletedQuorums
CSimplifiedMNListEntry()
Definition: simplifiedmns.h:35
Released under the MIT license