|
|
@ -212,7 +212,7 @@ void Shutdown() |
|
|
|
|
|
|
|
|
|
|
|
if (fFeeEstimatesInitialized) |
|
|
|
if (fFeeEstimatesInitialized) |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
CAutoFile est_fileout(fopen(est_path.string().c_str(), "wb"), SER_DISK, CLIENT_VERSION); |
|
|
|
CAutoFile est_fileout(fopen(est_path.string().c_str(), "wb"), SER_DISK, CLIENT_VERSION); |
|
|
|
if (!est_fileout.IsNull()) |
|
|
|
if (!est_fileout.IsNull()) |
|
|
|
mempool.WriteFeeEstimates(est_fileout); |
|
|
|
mempool.WriteFeeEstimates(est_fileout); |
|
|
@ -250,8 +250,8 @@ void Shutdown() |
|
|
|
|
|
|
|
|
|
|
|
#ifndef WIN32 |
|
|
|
#ifndef WIN32 |
|
|
|
try { |
|
|
|
try { |
|
|
|
boost::filesystem::remove(GetPidFile()); |
|
|
|
fs::remove(GetPidFile()); |
|
|
|
} catch (const boost::filesystem::filesystem_error& e) { |
|
|
|
} catch (const fs::filesystem_error& e) { |
|
|
|
LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); |
|
|
|
LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -578,14 +578,14 @@ struct CImportingNow |
|
|
|
// works correctly.
|
|
|
|
// works correctly.
|
|
|
|
void CleanupBlockRevFiles() |
|
|
|
void CleanupBlockRevFiles() |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::map<std::string, boost::filesystem::path> mapBlockFiles; |
|
|
|
std::map<std::string, fs::path> mapBlockFiles; |
|
|
|
|
|
|
|
|
|
|
|
// Glob all blk?????.dat and rev?????.dat files from the blocks directory.
|
|
|
|
// Glob all blk?????.dat and rev?????.dat files from the blocks directory.
|
|
|
|
// Remove the rev files immediately and insert the blk file paths into an
|
|
|
|
// Remove the rev files immediately and insert the blk file paths into an
|
|
|
|
// ordered map keyed by block file index.
|
|
|
|
// ordered map keyed by block file index.
|
|
|
|
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n"); |
|
|
|
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n"); |
|
|
|
boost::filesystem::path blocksdir = GetDataDir() / "blocks"; |
|
|
|
fs::path blocksdir = GetDataDir() / "blocks"; |
|
|
|
for (boost::filesystem::directory_iterator it(blocksdir); it != boost::filesystem::directory_iterator(); it++) { |
|
|
|
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) { |
|
|
|
if (is_regular_file(*it) && |
|
|
|
if (is_regular_file(*it) && |
|
|
|
it->path().filename().string().length() == 12 && |
|
|
|
it->path().filename().string().length() == 12 && |
|
|
|
it->path().filename().string().substr(8,4) == ".dat") |
|
|
|
it->path().filename().string().substr(8,4) == ".dat") |
|
|
@ -602,7 +602,7 @@ void CleanupBlockRevFiles() |
|
|
|
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
|
|
|
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
|
|
|
// start removing block files.
|
|
|
|
// start removing block files.
|
|
|
|
int nContigCounter = 0; |
|
|
|
int nContigCounter = 0; |
|
|
|
BOOST_FOREACH(const PAIRTYPE(std::string, boost::filesystem::path)& item, mapBlockFiles) { |
|
|
|
BOOST_FOREACH(const PAIRTYPE(std::string, fs::path)& item, mapBlockFiles) { |
|
|
|
if (atoi(item.first) == nContigCounter) { |
|
|
|
if (atoi(item.first) == nContigCounter) { |
|
|
|
nContigCounter++; |
|
|
|
nContigCounter++; |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -611,7 +611,7 @@ void CleanupBlockRevFiles() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) |
|
|
|
void ThreadImport(std::vector<fs::path> vImportFiles) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
RenameThread("bitcoin-loadblk"); |
|
|
|
RenameThread("bitcoin-loadblk"); |
|
|
@ -624,7 +624,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) |
|
|
|
int nFile = 0; |
|
|
|
int nFile = 0; |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
CDiskBlockPos pos(nFile, 0); |
|
|
|
CDiskBlockPos pos(nFile, 0); |
|
|
|
if (!boost::filesystem::exists(GetBlockPosFilename(pos, "blk"))) |
|
|
|
if (!fs::exists(GetBlockPosFilename(pos, "blk"))) |
|
|
|
break; // No block files left to reindex
|
|
|
|
break; // No block files left to reindex
|
|
|
|
FILE *file = OpenBlockFile(pos, true); |
|
|
|
FILE *file = OpenBlockFile(pos, true); |
|
|
|
if (!file) |
|
|
|
if (!file) |
|
|
@ -641,11 +641,11 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// hardcoded $DATADIR/bootstrap.dat
|
|
|
|
// hardcoded $DATADIR/bootstrap.dat
|
|
|
|
boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; |
|
|
|
fs::path pathBootstrap = GetDataDir() / "bootstrap.dat"; |
|
|
|
if (boost::filesystem::exists(pathBootstrap)) { |
|
|
|
if (fs::exists(pathBootstrap)) { |
|
|
|
FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); |
|
|
|
FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); |
|
|
|
if (file) { |
|
|
|
if (file) { |
|
|
|
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; |
|
|
|
fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; |
|
|
|
LogPrintf("Importing bootstrap.dat...\n"); |
|
|
|
LogPrintf("Importing bootstrap.dat...\n"); |
|
|
|
LoadExternalBlockFile(chainparams, file); |
|
|
|
LoadExternalBlockFile(chainparams, file); |
|
|
|
RenameOver(pathBootstrap, pathBootstrapOld); |
|
|
|
RenameOver(pathBootstrap, pathBootstrapOld); |
|
|
@ -655,7 +655,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -loadblock=
|
|
|
|
// -loadblock=
|
|
|
|
BOOST_FOREACH(const boost::filesystem::path& path, vImportFiles) { |
|
|
|
BOOST_FOREACH(const fs::path& path, vImportFiles) { |
|
|
|
FILE *file = fopen(path.string().c_str(), "rb"); |
|
|
|
FILE *file = fopen(path.string().c_str(), "rb"); |
|
|
|
if (file) { |
|
|
|
if (file) { |
|
|
|
LogPrintf("Importing blocks file %s...\n", path.string()); |
|
|
|
LogPrintf("Importing blocks file %s...\n", path.string()); |
|
|
@ -1123,7 +1123,7 @@ static bool LockDataDirectory(bool probeOnly) |
|
|
|
std::string strDataDir = GetDataDir().string(); |
|
|
|
std::string strDataDir = GetDataDir().string(); |
|
|
|
|
|
|
|
|
|
|
|
// Make sure only a single Bitcoin process is using the data directory.
|
|
|
|
// Make sure only a single Bitcoin process is using the data directory.
|
|
|
|
boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; |
|
|
|
fs::path pathLockFile = GetDataDir() / ".lock"; |
|
|
|
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
|
|
|
|
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
|
|
|
|
if (file) fclose(file); |
|
|
|
if (file) fclose(file); |
|
|
|
|
|
|
|
|
|
|
@ -1388,7 +1388,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
fReindex = GetBoolArg("-reindex", false); |
|
|
|
fReindex = GetBoolArg("-reindex", false); |
|
|
|
bool fReindexChainState = GetBoolArg("-reindex-chainstate", false); |
|
|
|
bool fReindexChainState = GetBoolArg("-reindex-chainstate", false); |
|
|
|
|
|
|
|
|
|
|
|
boost::filesystem::create_directories(GetDataDir() / "blocks"); |
|
|
|
fs::create_directories(GetDataDir() / "blocks"); |
|
|
|
|
|
|
|
|
|
|
|
// cache size calculations
|
|
|
|
// cache size calculations
|
|
|
|
int64_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20); |
|
|
|
int64_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20); |
|
|
@ -1534,7 +1534,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
} |
|
|
|
} |
|
|
|
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); |
|
|
|
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); |
|
|
|
|
|
|
|
|
|
|
|
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
CAutoFile est_filein(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION); |
|
|
|
CAutoFile est_filein(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION); |
|
|
|
// Allowed to fail as this file IS missing on first startup.
|
|
|
|
// Allowed to fail as this file IS missing on first startup.
|
|
|
|
if (!est_filein.IsNull()) |
|
|
|
if (!est_filein.IsNull()) |
|
|
@ -1590,7 +1590,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
if (IsArgSet("-blocknotify")) |
|
|
|
if (IsArgSet("-blocknotify")) |
|
|
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); |
|
|
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); |
|
|
|
|
|
|
|
|
|
|
|
std::vector<boost::filesystem::path> vImportFiles; |
|
|
|
std::vector<fs::path> vImportFiles; |
|
|
|
if (mapMultiArgs.count("-loadblock")) |
|
|
|
if (mapMultiArgs.count("-loadblock")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const std::string& strFile, mapMultiArgs.at("-loadblock")) |
|
|
|
BOOST_FOREACH(const std::string& strFile, mapMultiArgs.at("-loadblock")) |
|
|
|