Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 2,468 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
// use 25%-50% of the remainder for disk cache | // use 25%-50% of the remainder for disk cache | ||||
int64_t nCoinDBCache = | int64_t nCoinDBCache = | ||||
std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); | std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); | ||||
// cap total coins db cache | // cap total coins db cache | ||||
nCoinDBCache = std::min(nCoinDBCache, MAX_COINS_DB_CACHE_MB << 20); | nCoinDBCache = std::min(nCoinDBCache, MAX_COINS_DB_CACHE_MB << 20); | ||||
nTotalCache -= nCoinDBCache; | nTotalCache -= nCoinDBCache; | ||||
// the rest goes to in-memory cache | // the rest goes to in-memory cache | ||||
nCoinCacheUsage = nTotalCache; | int64_t nCoinCacheUsage = nTotalCache; | ||||
int64_t nMempoolSizeMax = | int64_t nMempoolSizeMax = | ||||
args.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; | args.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; | ||||
LogPrintf("Cache configuration:\n"); | LogPrintf("Cache configuration:\n"); | ||||
LogPrintf("* Using %.1f MiB for block index database\n", | LogPrintf("* Using %.1f MiB for block index database\n", | ||||
nBlockTreeDBCache * (1.0 / 1024 / 1024)); | nBlockTreeDBCache * (1.0 / 1024 / 1024)); | ||||
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | ||||
LogPrintf("* Using %.1f MiB for transaction index database\n", | LogPrintf("* Using %.1f MiB for transaction index database\n", | ||||
nTxIndexCache * (1.0 / 1024 / 1024)); | nTxIndexCache * (1.0 / 1024 / 1024)); | ||||
Show All 22 Lines | while (!fLoaded && !ShutdownRequested()) { | ||||
uiInterface.InitMessage(_("Loading block index...").translated); | uiInterface.InitMessage(_("Loading block index...").translated); | ||||
do { | do { | ||||
bool failed_verification = false; | bool failed_verification = false; | ||||
const int64_t load_block_index_start_time = GetTimeMillis(); | const int64_t load_block_index_start_time = GetTimeMillis(); | ||||
try { | try { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
chainman.InitializeChainstate(); | chainman.InitializeChainstate(); | ||||
chainman.m_total_coinstip_cache = nCoinCacheUsage; | |||||
chainman.m_total_coinsdb_cache = nCoinDBCache; | |||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
// new CBlockTreeDB tries to delete the existing file, which | // new CBlockTreeDB tries to delete the existing file, which | ||||
// fails if it's still open from the previous loop. Close it | // fails if it's still open from the previous loop. Close it | ||||
// first: | // first: | ||||
pblocktree.reset(); | pblocktree.reset(); | ||||
pblocktree.reset( | pblocktree.reset( | ||||
new CBlockTreeDB(nBlockTreeDBCache, false, fReset)); | new CBlockTreeDB(nBlockTreeDBCache, false, fReset)); | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | while (!fLoaded && !ShutdownRequested()) { | ||||
"Unable to replay blocks. You will need to rebuild " | "Unable to replay blocks. You will need to rebuild " | ||||
"the database using -reindex-chainstate."); | "the database using -reindex-chainstate."); | ||||
failed_chainstate_init = true; | failed_chainstate_init = true; | ||||
break; | break; | ||||
} | } | ||||
// The on-disk coinsdb is now in a good state, create the | // The on-disk coinsdb is now in a good state, create the | ||||
// cache | // cache | ||||
chainstate->InitCoinsCache(); | chainstate->InitCoinsCache(nCoinCacheUsage); | ||||
assert(chainstate->CanFlushToDisk()); | assert(chainstate->CanFlushToDisk()); | ||||
if (!is_coinsview_empty(chainstate)) { | if (!is_coinsview_empty(chainstate)) { | ||||
// LoadChainTip initializes the chain based on | // LoadChainTip initializes the chain based on | ||||
// CoinsTip()'s best block | // CoinsTip()'s best block | ||||
if (!chainstate->LoadChainTip(chainparams)) { | if (!chainstate->LoadChainTip(chainparams)) { | ||||
strLoadError = | strLoadError = | ||||
_("Error initializing block database"); | _("Error initializing block database"); | ||||
▲ Show 20 Lines • Show All 325 Lines • Show Last 20 Lines |