Raven Core  3.0.0
P2P Digital Currency
messagedb.h
Go to the documentation of this file.
1 // Copyright (c) 2019 The Raven 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 RAVENCOIN_MESSAGEDB_H
6 #define RAVENCOIN_MESSAGEDB_H
7 
8 #include <dbwrapper.h>
9 
10 class CMessage;
11 class COutPoint;
12 
13 class CMessageDB : public CDBWrapper {
14 
15 public:
16  explicit CMessageDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
17 
18  CMessageDB(const CMessageDB&) = delete;
19  CMessageDB& operator=(const CMessageDB&) = delete;
20 
21  // Database of messages
22  bool WriteMessage(const CMessage& message);
23  bool ReadMessage(const COutPoint& out, CMessage& message);
24  bool EraseMessage(const COutPoint& out);
25  bool LoadMessages(std::set<CMessage>& setMessages);
26  bool EraseAllMessages(int& count);
27 
28  // Write / Read Database flags
29  bool WriteFlag(const std::string &name, bool fValue);
30  bool ReadFlag(const std::string &name, bool &fValue);
31 
32  bool Flush();
33 };
34 
35 class CMessageChannelDB : public CDBWrapper {
36 public:
37  explicit CMessageChannelDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
38 
39  CMessageChannelDB(const CMessageChannelDB&) = delete;
41 
42  // My message channels
43  bool WriteMyMessageChannel(const std::string& channelname);
44  bool ReadMyMessageChannel(const std::string& channelname);
45  bool EraseMyMessageChannel(const std::string& channelname);
46  bool LoadMyMessageChannels(std::set<std::string>& setChannels);
47 
48  bool WriteUsedAddress(const std::string& address);
49  bool ReadUsedAddress(const std::string& address);
50  bool EraseUsedAddress(const std::string& address);
51 
52  // Write / Read Database flags
53  bool WriteFlag(const std::string &name, bool fValue);
54  bool ReadFlag(const std::string &name, bool &fValue);
55 
56  bool Flush();
57 };
58 
59 
60 #endif //RAVENCOIN_MESSAGEDB_H
bool Flush()
Definition: messagedb.cpp:90
bool LoadMessages(std::set< CMessage > &setMessages)
Definition: messagedb.cpp:32
CMessageDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: messagedb.cpp:14
bool EraseAllMessages(int &count)
Definition: messagedb.cpp:58
bool ReadMessage(const COutPoint &out, CMessage &message)
Definition: messagedb.cpp:22
bool ReadFlag(const std::string &name, bool &fValue)
Definition: messagedb.cpp:168
CMessageDB & operator=(const CMessageDB &)=delete
bool EraseMessage(const COutPoint &out)
Definition: messagedb.cpp:27
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
bool WriteMessage(const CMessage &message)
Definition: messagedb.cpp:17
bool WriteFlag(const std::string &name, bool fValue)
Definition: messagedb.cpp:163