PIVX Core  5.6.99
P2P Digital Currency
masternodeconfig.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2015 The Dash developers
2 // Copyright (c) 2015-2020 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or https://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_MASTERNODECONFIG_H
7 #define PIVX_MASTERNODECONFIG_H
8 
9 #include "sync.h"
10 #include <string>
11 #include <vector>
12 
13 class CMasternodeConfig;
15 
17 {
18 public:
20  {
21  private:
22  std::string alias;
23  std::string ip;
24  std::string privKey;
25  std::string txHash;
26  std::string outputIndex;
27 
28  public:
29  CMasternodeEntry(std::string& _alias, std::string& _ip, std::string& _privKey, std::string& _txHash, std::string& _outputIndex) :
30  alias(_alias), ip(_ip), privKey(_privKey), txHash(_txHash), outputIndex(_outputIndex) { }
31 
32  const std::string& getAlias() const { return alias; }
33  const std::string& getOutputIndex() const { return outputIndex; }
34  bool castOutputIndex(int& n) const;
35  const std::string& getPrivKey() const { return privKey; }
36  const std::string& getTxHash() const { return txHash; }
37  const std::string& getIp() const { return ip; }
38  };
39 
40  CMasternodeConfig() { entries = std::vector<CMasternodeEntry>(); }
41 
42  void clear() { LOCK(cs_entries); entries.clear(); }
43  bool read(std::string& strErr);
44  CMasternodeConfig::CMasternodeEntry* add(std::string alias, std::string ip, std::string privKey, std::string txHash, std::string outputIndex);
45  void remove(std::string alias);
46 
47  std::vector<CMasternodeEntry> getEntries() { LOCK(cs_entries); return entries; }
48 
49  int getCount()
50  {
52  int c = -1;
53  for (const auto& e : entries) {
54  if (!e.getAlias().empty()) c++;
55  }
56  return c;
57  }
58 
59 private:
60  std::vector<CMasternodeEntry> entries;
62 };
63 
64 
65 #endif // PIVX_MASTERNODECONFIG_H
CService ip(uint32_t i)
Definition: DoS_tests.cpp:39
const std::string & getTxHash() const
std::string alias
std::string ip
CMasternodeEntry(std::string &_alias, std::string &_ip, std::string &_privKey, std::string &_txHash, std::string &_outputIndex)
std::string privKey
const std::string & getOutputIndex() const
const std::string & getIp() const
bool castOutputIndex(int &n) const
const std::string & getPrivKey() const
const std::string & getAlias() const
std::string outputIndex
std::string txHash
bool read(std::string &strErr)
void remove(std::string alias)
CMasternodeConfig::CMasternodeEntry * add(std::string alias, std::string ip, std::string privKey, std::string txHash, std::string outputIndex)
std::vector< CMasternodeEntry > entries
std::vector< CMasternodeEntry > getEntries()
@ LOCK
Definition: lockunlock.h:16
CMasternodeConfig masternodeConfig