| 1244 | } |
| 1245 | |
| 1246 | bool 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); |
no test coverage detected