Browse Source

init.cpp: log fee estimates filename on error

- small changes to Shutdown(), buffer __func__, which is now used in
  all LogPrintf() calls and format for better readability
- order using namespace alpabetically
0.10
Philip Kaufmann 11 years ago
parent
commit
00d1980b8f
  1. 26
      src/init.cpp

26
src/init.cpp

@ -38,8 +38,8 @@
#include <boost/interprocess/sync/file_lock.hpp> #include <boost/interprocess/sync/file_lock.hpp>
#include <openssl/crypto.h> #include <openssl/crypto.h>
using namespace std;
using namespace boost; using namespace boost;
using namespace std;
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
CWallet* pwalletMain; CWallet* pwalletMain;
@ -109,10 +109,11 @@ static CCoinsViewDB *pcoinsdbview;
void Shutdown() void Shutdown()
{ {
LogPrintf("Shutdown : In progress...\n"); LogPrintf("%s: In progress...\n", __func__);
static CCriticalSection cs_Shutdown; static CCriticalSection cs_Shutdown;
TRY_LOCK(cs_Shutdown, lockShutdown); TRY_LOCK(cs_Shutdown, lockShutdown);
if (!lockShutdown) return; if (!lockShutdown)
return;
RenameThread("bitcoin-shutoff"); RenameThread("bitcoin-shutoff");
mempool.AddTransactionsUpdated(1); mempool.AddTransactionsUpdated(1);
@ -130,7 +131,7 @@ void Shutdown()
if (est_fileout) if (est_fileout)
mempool.WriteFeeEstimates(est_fileout); mempool.WriteFeeEstimates(est_fileout);
else else
LogPrintf("failed to write fee estimates"); LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
{ {
LOCK(cs_main); LOCK(cs_main);
@ -142,9 +143,12 @@ void Shutdown()
pblocktree->Flush(); pblocktree->Flush();
if (pcoinsTip) if (pcoinsTip)
pcoinsTip->Flush(); pcoinsTip->Flush();
delete pcoinsTip; pcoinsTip = NULL; delete pcoinsTip;
delete pcoinsdbview; pcoinsdbview = NULL; pcoinsTip = NULL;
delete pblocktree; pblocktree = NULL; delete pcoinsdbview;
pcoinsdbview = NULL;
delete pblocktree;
pblocktree = NULL;
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (pwalletMain) if (pwalletMain)
@ -156,7 +160,7 @@ void Shutdown()
if (pwalletMain) if (pwalletMain)
delete pwalletMain; delete pwalletMain;
#endif #endif
LogPrintf("Shutdown : done\n"); LogPrintf("%s: done\n", __func__);
} }
// //
@ -315,6 +319,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += "\n" + _("Node relay options:") + "\n"; strUsage += "\n" + _("Node relay options:") + "\n";
strUsage += " -datacarrier " + _("Relay and mine data carrier transactions (default: 1)") + "\n"; strUsage += " -datacarrier " + _("Relay and mine data carrier transactions (default: 1)") + "\n";
strUsage += "\n" + _("Block creation options:") + "\n"; strUsage += "\n" + _("Block creation options:") + "\n";
strUsage += " -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n"; strUsage += " -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n";
strUsage += " -blockmaxsize=<n> " + strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE) + "\n"; strUsage += " -blockmaxsize=<n> " + strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE) + "\n";
@ -564,9 +569,9 @@ bool AppInit2(boost::thread_group& threadGroup)
if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end()) if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end())
fDebug = false; fDebug = false;
// Check for -debugnet (deprecated) // Check for -debugnet
if (GetBoolArg("-debugnet", false)) if (GetBoolArg("-debugnet", false))
InitWarning(_("Warning: Deprecated argument -debugnet ignored, use -debug=net")); InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net."));
// Check for -socks - as this is a privacy risk to continue, exit here // Check for -socks - as this is a privacy risk to continue, exit here
if (mapArgs.count("-socks")) if (mapArgs.count("-socks"))
return InitError(_("Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported.")); return InitError(_("Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
@ -994,6 +999,7 @@ bool AppInit2(boost::thread_group& threadGroup)
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
CAutoFile est_filein = CAutoFile(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION); CAutoFile est_filein = CAutoFile(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION);
// Allowed to fail as this file IS missing on first startup.
if (est_filein) if (est_filein)
mempool.ReadFeeEstimates(est_filein); mempool.ReadFeeEstimates(est_filein);

Loading…
Cancel
Save