11 static const int BUDGET_DB_VERSION = 1;
29 ssObj << BUDGET_DB_VERSION;
40 return error(
"%s : Failed to open file %s", __func__,
pathDB.string());
45 }
catch (
const std::exception& e) {
46 return error(
"%s : Serialize or I/O error - %s", __func__, e.what());
62 error(
"%s : Failed to open file %s", __func__,
pathDB.string());
67 int fileSize = fs::file_size(
pathDB);
68 int dataSize = fileSize -
sizeof(
uint256);
72 std::vector<unsigned char> vchData;
73 vchData.resize(dataSize);
78 filein.
read((
char*)vchData.data(), dataSize);
80 }
catch (
const std::exception& e) {
81 error(
"%s : Deserialize or I/O error - %s", __func__, e.what());
90 if (hashIn != hashTmp) {
91 error(
"%s : Checksum mismatch, data corrupted", __func__);
96 std::string strMagicMessageTmp;
100 ssObj >> strMagicMessageTmp;
104 error(
"%s : Invalid masternode cache magic message", __func__);
109 std::vector<unsigned char> pchMsgTmp(4);
113 if (memcmp(pchMsgTmp.data(),
Params().MessageStart(), pchMsgTmp.size()) != 0) {
114 error(
"%s : Invalid network magic number", __func__);
120 }
catch (
const std::exception& e) {
122 error(
"%s : Deserialize or I/O error - %s", __func__, e.what());
143 budgetdb.
Write(budgetman);
void DumpBudgets(CBudgetManager &budgetman)
const CChainParams & Params()
Return the currently selected parameters.
Non-refcounted RAII wrapper for FILE*.
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
void read(char *pch, size_t nSize)
const_iterator end() const
const_iterator begin() const
Save Budget Manager (budget.dat)
std::string strMagicMessage
bool Write(const CBudgetManager &objToSave)
ReadResult Read(CBudgetManager &objToLoad, bool fDryRun=false)
std::string ToString() const
const CMessageHeader::MessageStartChars & MessageStart() const
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
#define LogPrint(category,...)
FILE * fopen(const fs::path &p, const char *mode)
constexpr Span< A > MakeSpan(A(&a)[N])
MakeSpan for arrays:
const fs::path & GetDataDir(bool fNetSpecific)
bool error(const char *fmt, const Args &... args)
int64_t GetTimeMillis()
Returns the system time (not mockable)