MCPcopy Create free account
hub / github.com/ElementsProject/elements / AppInitMain

Function AppInitMain

src/init.cpp:1246–2020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1244}
1245
1246bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1247{
1248 const ArgsManager& args = *Assert(node.args);
1249 const CChainParams& chainparams = Params();
1250
1251 CBlockIndex::SetNodeContext(&node);
1252 auto opt_max_upload = ParseByteUnits(args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET), ByteUnit::M);
1253 if (!opt_max_upload) {
1254 return InitError(strprintf(_("Unable to parse -maxuploadtarget: '%s'"), args.GetArg("-maxuploadtarget", "")));
1255 }
1256
1257 // ********************************************************* Step 4a: application initialization
1258 if (!CreatePidFile(args)) {
1259 // Detailed error printed inside CreatePidFile().
1260 return false;
1261 }
1262 if (!init::StartLogging(args)) {
1263 // Detailed error printed inside StartLogging().
1264 return false;
1265 }
1266
1267 LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1268
1269 // Warn about relative -datadir path.
1270 if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) {
1271 LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */
1272 "current working directory '%s'. This is fragile, because if bitcoin is started in the future "
1273 "from a different location, it will be unable to locate the current data files. There could "
1274 "also be data loss if bitcoin is started while in a temporary directory.\n",
1275 args.GetArg("-datadir", ""), fs::PathToString(fs::current_path()));
1276 }
1277
1278 InitSignatureCache();
1279 InitScriptExecutionCache();
1280 InitRangeproofCache();
1281 InitSurjectionproofCache();
1282
1283
1284 int script_threads = args.GetIntArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
1285 if (script_threads <= 0) {
1286 // -par=0 means autodetect (number of cores - 1 script threads)
1287 // -par=-n means "leave n cores free" (number of cores - n - 1 script threads)
1288 script_threads += GetNumCores();
1289 }
1290
1291 // Subtract 1 because the main thread counts towards the par threads
1292 script_threads = std::max(script_threads - 1, 0);
1293
1294 // Number of script-checking threads <= MAX_SCRIPTCHECK_THREADS
1295 script_threads = std::min(script_threads, MAX_SCRIPTCHECK_THREADS);
1296
1297 LogPrintf("Script verification uses %d additional threads\n", script_threads);
1298 if (script_threads >= 1) {
1299 g_parallel_script_checks = true;
1300 StartScriptCheckWorkerThreads(script_threads);
1301 }
1302
1303 assert(!node.scheduler);

Callers 2

AppInitFunction · 0.85
appInitMainMethod · 0.85

Calls 15

ParseByteUnitsFunction · 0.85
InitErrorFunction · 0.85
_Function · 0.85
CreatePidFileFunction · 0.85
StartLoggingFunction · 0.85
PathToStringFunction · 0.85
InitSignatureCacheFunction · 0.85
InitScriptExecutionCacheFunction · 0.85
InitRangeproofCacheFunction · 0.85
InitSurjectionproofCacheFunction · 0.85
GetNumCoresFunction · 0.85

Tested by

no test coverage detected