Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

governance-votedb.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2019 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 
5 #ifndef GOVERNANCE_VOTEDB_H
6 #define GOVERNANCE_VOTEDB_H
7 
8 #include <list>
9 #include <map>
10 
12 #include <serialize.h>
13 #include <streams.h>
14 #include <uint256.h>
15 
25 {
26 public: // Types
27  typedef std::list<CGovernanceVote> vote_l_t;
28 
29  typedef vote_l_t::iterator vote_l_it;
30 
31  typedef vote_l_t::const_iterator vote_l_cit;
32 
33  typedef std::map<uint256, vote_l_it> vote_m_t;
34 
35  typedef vote_m_t::iterator vote_m_it;
36 
37  typedef vote_m_t::const_iterator vote_m_cit;
38 
39 private:
41 
43 
45 
46 public:
48 
50 
54  void AddVote(const CGovernanceVote& vote);
55 
59  bool HasVote(const uint256& nHash) const;
60 
64  bool SerializeVoteToStream(const uint256& nHash, CDataStream& ss) const;
65 
67  {
68  return nMemoryVotes;
69  }
70 
71  std::vector<CGovernanceVote> GetVotes() const;
72 
73  void RemoveVotesFromMasternode(const COutPoint& outpointMasternode);
74  std::set<uint256> RemoveInvalidVotes(const COutPoint& outpointMasternode, bool fProposal);
75 
77 
78  template <typename Stream, typename Operation>
79  inline void SerializationOp(Stream& s, Operation ser_action)
80  {
83  if (ser_action.ForRead()) {
84  RebuildIndex();
85  }
86  }
87 
88 private:
89  // Drop older votes for the same gobject from the same masternode
90  void RemoveOldVotes(const CGovernanceVote& vote);
91 
92  void RebuildIndex();
93 };
94 
95 #endif
bool HasVote(const uint256 &nHash) const
Return true if the vote with this hash is currently cached in memory.
void SerializationOp(Stream &s, Operation ser_action)
void RemoveOldVotes(const CGovernanceVote &vote)
#define READWRITE(obj)
Definition: serialize.h:165
vote_m_t::iterator vote_m_it
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
vote_l_t::const_iterator vote_l_cit
void RemoveVotesFromMasternode(const COutPoint &outpointMasternode)
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
std::list< CGovernanceVote > vote_l_t
256-bit opaque blob.
Definition: uint256.h:123
vote_l_t::iterator vote_l_it
void AddVote(const CGovernanceVote &vote)
Add a vote to the file.
std::map< uint256, vote_l_it > vote_m_t
std::vector< CGovernanceVote > GetVotes() const
Represents the collection of votes associated with a given CGovernanceObject Recently received votes ...
std::set< uint256 > RemoveInvalidVotes(const COutPoint &outpointMasternode, bool fProposal)
bool SerializeVoteToStream(const uint256 &nHash, CDataStream &ss) const
Retrieve a vote cached in memory.
vote_m_t::const_iterator vote_m_cit
Released under the MIT license