Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.cpp
Show First 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | BerkeleyEnvironment::Verify(const std::string &strFile, | ||||
} | } | ||||
// Try to recover: | // Try to recover: | ||||
bool fRecovered = | bool fRecovered = | ||||
(*recoverFunc)(fs::path(strPath) / strFile, out_backup_filename); | (*recoverFunc)(fs::path(strPath) / strFile, out_backup_filename); | ||||
return (fRecovered ? VerifyResult::RECOVER_OK : VerifyResult::RECOVER_FAIL); | return (fRecovered ? VerifyResult::RECOVER_OK : VerifyResult::RECOVER_FAIL); | ||||
} | } | ||||
BerkeleyBatch::SafeDbt::SafeDbt(u_int32_t flags) { | |||||
m_dbt.set_flags(flags); | |||||
} | |||||
BerkeleyBatch::SafeDbt::SafeDbt(void *data, size_t size) : m_dbt(data, size) {} | |||||
BerkeleyBatch::SafeDbt::~SafeDbt() { | |||||
if (m_dbt.get_data() != nullptr) { | |||||
// Clear memory, e.g. in case it was a private key | |||||
memory_cleanse(m_dbt.get_data(), m_dbt.get_size()); | |||||
// under DB_DBT_MALLOC, data is malloced by the Dbt, but must be | |||||
// freed by the caller. | |||||
// https://docs.oracle.com/cd/E17275_01/html/api_reference/C/dbt.html | |||||
if (m_dbt.get_flags() & DB_DBT_MALLOC) { | |||||
free(m_dbt.get_data()); | |||||
} | |||||
} | |||||
} | |||||
const void *BerkeleyBatch::SafeDbt::get_data() const { | |||||
return m_dbt.get_data(); | |||||
} | |||||
u_int32_t BerkeleyBatch::SafeDbt::get_size() const { | |||||
return m_dbt.get_size(); | |||||
} | |||||
BerkeleyBatch::SafeDbt::operator Dbt *() { | |||||
return &m_dbt; | |||||
} | |||||
bool BerkeleyBatch::Recover(const fs::path &file_path, void *callbackDataIn, | bool BerkeleyBatch::Recover(const fs::path &file_path, void *callbackDataIn, | ||||
bool (*recoverKVcallback)(void *callbackData, | bool (*recoverKVcallback)(void *callbackData, | ||||
CDataStream ssKey, | CDataStream ssKey, | ||||
CDataStream ssValue), | CDataStream ssValue), | ||||
std::string &newFilename) { | std::string &newFilename) { | ||||
std::string filename; | std::string filename; | ||||
std::shared_ptr<BerkeleyEnvironment> env = | std::shared_ptr<BerkeleyEnvironment> env = | ||||
GetWalletEnv(file_path, filename); | GetWalletEnv(file_path, filename); | ||||
▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines |