Move BackupWallet to CWallet::BackupWallet
This commit is contained in:
committed by
lateminer
parent
261efcf69a
commit
db3b5d964a
@@ -3875,6 +3875,46 @@ bool CWallet::ParameterInteraction()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWallet::BackupWallet(const std::string& strDest)
|
||||
{
|
||||
if (!fFileBacked)
|
||||
return false;
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
LOCK(bitdb.cs_db);
|
||||
if (!bitdb.mapFileUseCount.count(strWalletFile) || bitdb.mapFileUseCount[strWalletFile] == 0)
|
||||
{
|
||||
// Flush log data to the dat file
|
||||
bitdb.CloseDb(strWalletFile);
|
||||
bitdb.CheckpointLSN(strWalletFile);
|
||||
bitdb.mapFileUseCount.erase(strWalletFile);
|
||||
|
||||
// Copy wallet file
|
||||
boost::filesystem::path pathSrc = GetDataDir() / strWalletFile;
|
||||
boost::filesystem::path pathDest(strDest);
|
||||
if (boost::filesystem::is_directory(pathDest))
|
||||
pathDest /= strWalletFile;
|
||||
|
||||
try {
|
||||
#if BOOST_VERSION >= 104000
|
||||
boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists);
|
||||
#else
|
||||
boost::filesystem::copy_file(pathSrc, pathDest);
|
||||
#endif
|
||||
LogPrintf("copied %s to %s\n", strWalletFile, pathDest.string());
|
||||
return true;
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
LogPrintf("error copying %s to %s - %s\n", strWalletFile, pathDest.string(), e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
MilliSleep(100);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyPool::CKeyPool()
|
||||
{
|
||||
nTime = GetTime();
|
||||
|
||||
Reference in New Issue
Block a user