Dash Core  0.12.2.1
P2P Digital Currency
governance-votedb.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 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 
11 #include "governance-vote.h"
12 #include "serialize.h"
13 #include "uint256.h"
14 
24 {
25 public: // Types
26  typedef std::list<CGovernanceVote> vote_l_t;
27 
28  typedef vote_l_t::iterator vote_l_it;
29 
30  typedef vote_l_t::const_iterator vote_l_cit;
31 
32  typedef std::map<uint256,vote_l_it> vote_m_t;
33 
34  typedef vote_m_t::iterator vote_m_it;
35 
36  typedef vote_m_t::const_iterator vote_m_cit;
37 
38 private:
39  static const int MAX_MEMORY_VOTES = -1;
40 
42 
44 
46 
47 public:
49 
51 
55  void AddVote(const CGovernanceVote& vote);
56 
60  bool HasVote(const uint256& nHash) const;
61 
65  bool GetVote(const uint256& nHash, CGovernanceVote& vote) const;
66 
67  int GetVoteCount() {
68  return nMemoryVotes;
69  }
70 
71  std::vector<CGovernanceVote> GetVotes() const;
72 
74 
75  void RemoveVotesFromMasternode(const COutPoint& outpointMasternode);
76 
78 
79  template <typename Stream, typename Operation>
80  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
81  {
84  if(ser_action.ForRead()) {
85  RebuildIndex();
86  }
87  }
88 private:
89  void RebuildIndex();
90 
91 };
92 
93 #endif
vote_l_t::iterator vote_l_it
std::vector< CGovernanceVote > GetVotes() const
#define READWRITE(obj)
Definition: serialize.h:175
void AddVote(const CGovernanceVote &vote)
bool GetVote(const uint256 &nHash, CGovernanceVote &vote) const
std::map< uint256, vote_l_it > vote_m_t
std::list< CGovernanceVote > vote_l_t
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
void RemoveVotesFromMasternode(const COutPoint &outpointMasternode)
static const int MAX_MEMORY_VOTES
bool HasVote(const uint256 &nHash) const
CGovernanceObjectVoteFile & operator=(const CGovernanceObjectVoteFile &other)
vote_m_t::const_iterator vote_m_cit
vote_m_t::iterator vote_m_it
vote_l_t::const_iterator vote_l_cit