Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | static void registerSignalHandler(int signal, void (*handler)(int)) { | ||||
struct sigaction sa; | struct sigaction sa; | ||||
sa.sa_handler = handler; | sa.sa_handler = handler; | ||||
sigemptyset(&sa.sa_mask); | sigemptyset(&sa.sa_mask); | ||||
sa.sa_flags = 0; | sa.sa_flags = 0; | ||||
sigaction(signal, &sa, NULL); | sigaction(signal, &sa, NULL); | ||||
} | } | ||||
#endif | #endif | ||||
void OnRPCStarted() { | static void OnRPCStarted() { | ||||
uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange); | uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange); | ||||
} | } | ||||
void OnRPCStopped() { | static void OnRPCStopped() { | ||||
uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange); | uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange); | ||||
RPCNotifyBlockChange(false, nullptr); | RPCNotifyBlockChange(false, nullptr); | ||||
g_best_block_cv.notify_all(); | g_best_block_cv.notify_all(); | ||||
LogPrint(BCLog::RPC, "RPC stopped.\n"); | LogPrint(BCLog::RPC, "RPC stopped.\n"); | ||||
} | } | ||||
void SetupServerArgs() { | void SetupServerArgs() { | ||||
const auto defaultBaseParams = | const auto defaultBaseParams = | ||||
▲ Show 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | |||||
// If we're using -prune with -reindex, then delete block files that will be | // If we're using -prune with -reindex, then delete block files that will be | ||||
// ignored by the reindex. Since reindexing works by starting at block file 0 | // ignored by the reindex. Since reindexing works by starting at block file 0 | ||||
// and looping until a blockfile is missing, do the same here to delete any | // and looping until a blockfile is missing, do the same here to delete any | ||||
// later block files after a gap. Also delete all rev files since they'll be | // later block files after a gap. Also delete all rev files since they'll be | ||||
// rewritten by the reindex anyway. This ensures that vinfoBlockFile is in sync | // rewritten by the reindex anyway. This ensures that vinfoBlockFile is in sync | ||||
// with what's actually on disk by the time we start downloading, so that | // with what's actually on disk by the time we start downloading, so that | ||||
// pruning works correctly. | // pruning works correctly. | ||||
void CleanupBlockRevFiles() { | static void CleanupBlockRevFiles() { | ||||
std::map<std::string, fs::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 " | LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for " | ||||
"-reindex with -prune\n"); | "-reindex with -prune\n"); | ||||
fs::path blocksdir = GetBlocksDir(); | fs::path blocksdir = GetBlocksDir(); | ||||
Show All 20 Lines | for (const std::pair<std::string, fs::path> &item : mapBlockFiles) { | ||||
if (atoi(item.first) == nContigCounter) { | if (atoi(item.first) == nContigCounter) { | ||||
nContigCounter++; | nContigCounter++; | ||||
continue; | continue; | ||||
} | } | ||||
remove(item.second); | remove(item.second); | ||||
} | } | ||||
} | } | ||||
void ThreadImport(const Config &config, std::vector<fs::path> vImportFiles) { | static void ThreadImport(const Config &config, | ||||
std::vector<fs::path> vImportFiles) { | |||||
RenameThread("bitcoin-loadblk"); | RenameThread("bitcoin-loadblk"); | ||||
{ | { | ||||
CImportingNow imp; | CImportingNow imp; | ||||
// -reindex | // -reindex | ||||
if (fReindex) { | if (fReindex) { | ||||
int nFile = 0; | int nFile = 0; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static void ThreadImport(const Config &config, | ||||
} | } | ||||
g_is_mempool_loaded = !fRequestShutdown; | g_is_mempool_loaded = !fRequestShutdown; | ||||
} | } | ||||
/** Sanity checks | /** Sanity checks | ||||
* Ensure that Bitcoin is running in a usable environment with all | * Ensure that Bitcoin is running in a usable environment with all | ||||
* necessary library support. | * necessary library support. | ||||
*/ | */ | ||||
bool InitSanityCheck(void) { | static bool InitSanityCheck(void) { | ||||
if (!ECC_InitSanityCheck()) { | if (!ECC_InitSanityCheck()) { | ||||
InitError( | InitError( | ||||
"Elliptic curve cryptography sanity check failure. Aborting."); | "Elliptic curve cryptography sanity check failure. Aborting."); | ||||
return false; | return false; | ||||
} | } | ||||
if (!glibc_sanity_test() || !glibcxx_sanity_test()) { | if (!glibc_sanity_test() || !glibcxx_sanity_test()) { | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 1,278 Lines • Show Last 20 Lines |