PIVX Core  5.6.99
P2P Digital Currency
sporkdb.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2020 The PIVX 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 #include "sporkdb.h"
6 #include "spork.h"
7 
8 CSporkDB::CSporkDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "sporks", nCacheSize, fMemory, fWipe) {}
9 
10 bool CSporkDB::WriteSpork(const SporkId nSporkId, const CSporkMessage& spork)
11 {
12  LogPrintf("Wrote spork %s to database\n", sporkManager.GetSporkNameByID(nSporkId));
13  return Write(nSporkId, spork);
14 
15 }
16 
18 {
19  return Read(nSporkId, spork);
20 }
21 
22 bool CSporkDB::SporkExists(const SporkId nSporkId)
23 {
24  return Exists(nSporkId);
25 }
bool Read(const K &key, V &value) const
Definition: dbwrapper.h:260
bool Write(const K &key, const V &value, bool fSync=false)
Definition: dbwrapper.h:284
bool Exists(const K &key) const
Definition: dbwrapper.h:292
bool WriteSpork(const SporkId nSporkId, const CSporkMessage &spork)
Definition: sporkdb.cpp:10
CSporkDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: sporkdb.cpp:8
bool SporkExists(const SporkId nSporkId)
Definition: sporkdb.cpp:22
bool ReadSpork(const SporkId nSporkId, CSporkMessage &spork)
Definition: sporkdb.cpp:17
std::string GetSporkNameByID(SporkId id)
Definition: spork.cpp:255
UniValue spork(const JSONRPCRequest &request)
Definition: misc.cpp:286
CSporkManager sporkManager
Definition: spork.cpp:29
SporkId
Definition: sporkid.h:14
const fs::path & GetDataDir(bool fNetSpecific)
Definition: system.cpp:724