Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,867 Lines • ▼ Show 20 Lines | static bool LockDataDirectory(bool probeOnly) { | ||||
if (!DirIsWritable(datadir)) { | if (!DirIsWritable(datadir)) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Cannot write to data directory '%s'; check permissions."), | _("Cannot write to data directory '%s'; check permissions."), | ||||
datadir.string())); | datadir.string())); | ||||
} | } | ||||
if (!LockDirectory(datadir, ".lock", probeOnly)) { | if (!LockDirectory(datadir, ".lock", probeOnly)) { | ||||
return InitError(strprintf(_("Cannot obtain a lock on data directory " | return InitError(strprintf(_("Cannot obtain a lock on data directory " | ||||
"%s. %s is probably already running."), | "%s. %s is probably already running."), | ||||
datadir.string(), _(PACKAGE_NAME))); | datadir.string(), PACKAGE_NAME)); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool AppInitSanityChecks() { | bool AppInitSanityChecks() { | ||||
// Step 4: sanity checks | // Step 4: sanity checks | ||||
// Initialize elliptic curve code | // Initialize elliptic curve code | ||||
std::string sha256_algo = SHA256AutoDetect(); | std::string sha256_algo = SHA256AutoDetect(); | ||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo); | LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo); | ||||
RandomInit(); | RandomInit(); | ||||
ECC_Start(); | ECC_Start(); | ||||
globalVerifyHandle.reset(new ECCVerifyHandle()); | globalVerifyHandle.reset(new ECCVerifyHandle()); | ||||
// Sanity check | // Sanity check | ||||
if (!InitSanityCheck()) { | if (!InitSanityCheck()) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Initialization sanity check failed. %s is shutting down."), | _("Initialization sanity check failed. %s is shutting down."), | ||||
_(PACKAGE_NAME))); | PACKAGE_NAME)); | ||||
} | } | ||||
// Probe the data directory lock to give an early error message, if possible | // Probe the data directory lock to give an early error message, if possible | ||||
// We cannot hold the data directory lock here, as the forking for daemon() | // We cannot hold the data directory lock here, as the forking for daemon() | ||||
// hasn't yet happened, and a fork will cause weird behavior to it. | // hasn't yet happened, and a fork will cause weird behavior to it. | ||||
return LockDataDirectory(true); | return LockDataDirectory(true); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines |