Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 2,254 Lines • ▼ Show 20 Lines | #endif | ||||
assert(!node.banman); | assert(!node.banman); | ||||
node.banman = std::make_unique<BanMan>( | node.banman = std::make_unique<BanMan>( | ||||
GetDataDir() / "banlist.dat", config.GetChainParams(), &uiInterface, | GetDataDir() / "banlist.dat", config.GetChainParams(), &uiInterface, | ||||
args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME)); | args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME)); | ||||
assert(!node.connman); | assert(!node.connman); | ||||
node.connman = std::make_unique<CConnman>( | node.connman = std::make_unique<CConnman>( | ||||
config, GetRand(std::numeric_limits<uint64_t>::max()), | config, GetRand(std::numeric_limits<uint64_t>::max()), | ||||
GetRand(std::numeric_limits<uint64_t>::max())); | GetRand(std::numeric_limits<uint64_t>::max())); | ||||
// Make mempool generally available in the node context. For example the | |||||
// connection manager, wallet, or RPC threads, which are all started after | |||||
// this, may use it from the node context. | |||||
assert(!node.mempool); | |||||
node.mempool = &::g_mempool; | |||||
assert(!node.chainman); | assert(!node.chainman); | ||||
node.chainman = &g_chainman; | node.chainman = &g_chainman; | ||||
ChainstateManager &chainman = *Assert(node.chainman); | ChainstateManager &chainman = *Assert(node.chainman); | ||||
node.peer_logic.reset(new PeerLogicValidation( | node.peer_logic.reset( | ||||
node.connman.get(), node.banman.get(), *node.scheduler, chainman)); | new PeerLogicValidation(node.connman.get(), node.banman.get(), | ||||
*node.scheduler, chainman, *node.mempool)); | |||||
RegisterValidationInterface(node.peer_logic.get()); | RegisterValidationInterface(node.peer_logic.get()); | ||||
// sanitize comments per BIP-0014, format user agent and check total size | // sanitize comments per BIP-0014, format user agent and check total size | ||||
std::vector<std::string> uacomments; | std::vector<std::string> uacomments; | ||||
for (const std::string &cmt : args.GetArgs("-uacomment")) { | for (const std::string &cmt : args.GetArgs("-uacomment")) { | ||||
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) { | if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("User Agent comment (%s) contains unsafe characters."), cmt)); | _("User Agent comment (%s) contains unsafe characters."), cmt)); | ||||
▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | if (ShutdownRequested()) { | ||||
LogPrintf("Shutdown requested. Exiting.\n"); | LogPrintf("Shutdown requested. Exiting.\n"); | ||||
return false; | return false; | ||||
} | } | ||||
// Encoded addresses using cashaddr instead of base58. | // Encoded addresses using cashaddr instead of base58. | ||||
// We do this by default to avoid confusion with BTC addresses. | // We do this by default to avoid confusion with BTC addresses. | ||||
config.SetCashAddrEncoding(args.GetBoolArg("-usecashaddr", true)); | config.SetCashAddrEncoding(args.GetBoolArg("-usecashaddr", true)); | ||||
// Now that the chain state is loaded, make mempool generally available in | |||||
// the node context. For example the connection manager, wallet, or RPC | |||||
// threads, which are all started after this, may use it from the node | |||||
// context. | |||||
assert(!node.mempool); | |||||
node.mempool = &::g_mempool; | |||||
// Step 8: load indexers | // Step 8: load indexers | ||||
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | ||||
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex); | g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex); | ||||
g_txindex->Start(); | g_txindex->Start(); | ||||
} | } | ||||
for (const auto &filter_type : g_enabled_filter_types) { | for (const auto &filter_type : g_enabled_filter_types) { | ||||
InitBlockFilterIndex(filter_type, filter_index_cache, false, fReindex); | InitBlockFilterIndex(filter_type, filter_index_cache, false, fReindex); | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |