Initialize Coin. * @pre Parameters should be parsed and config file should be read. */
| 419 | * @pre Parameters should be parsed and config file should be read. |
| 420 | */ |
| 421 | bool AppInit(boost::thread_group &threadGroup) { |
| 422 | #ifdef _MSC_VER |
| 423 | // Turn off Microsoft heap dump noise |
| 424 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 425 | _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); |
| 426 | #endif |
| 427 | #if _MSC_VER >= 1400 |
| 428 | // Disable confusing "helpful" text message on abort, Ctrl-C |
| 429 | _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); |
| 430 | #endif |
| 431 | #ifdef WIN32 |
| 432 | // Enable Data Execution Prevention (DEP) |
| 433 | // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008 |
| 434 | // A failure is non-critical and needs no further attention! |
| 435 | #ifndef PROCESS_DEP_ENABLE |
| 436 | // We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7), |
| 437 | // which is not correct. Can be removed, when GCCs winbase.h is fixed! |
| 438 | #define PROCESS_DEP_ENABLE 0x00000001 |
| 439 | #endif |
| 440 | typedef BOOL(WINAPI * PSETPROCDEPPOL)(DWORD); |
| 441 | PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); |
| 442 | if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE); |
| 443 | |
| 444 | // Initialize Windows Sockets |
| 445 | WSADATA wsadata; |
| 446 | int32_t ret = WSAStartup(MAKEWORD(2, 2), &wsadata); |
| 447 | if (ret != NO_ERROR || LOBYTE(wsadata.wVersion) != 2 || HIBYTE(wsadata.wVersion) != 2) |
| 448 | return InitError(strprintf("Error: Winsock library failed to start (WSAStartup returned error %d)", ret)); |
| 449 | |
| 450 | #endif |
| 451 | #ifndef WIN32 |
| 452 | umask(077); |
| 453 | |
| 454 | // Clean shutdown on SIGTERM |
| 455 | struct sigaction sa; |
| 456 | sa.sa_handler = HandleSIGTERM; |
| 457 | sigemptyset(&sa.sa_mask); |
| 458 | sa.sa_flags = 0; |
| 459 | sigaction(SIGTERM, &sa, nullptr); |
| 460 | sigaction(SIGINT, &sa, nullptr); |
| 461 | |
| 462 | // Reopen debug.log on SIGHUP |
| 463 | struct sigaction sa_hup; |
| 464 | sa_hup.sa_handler = HandleSIGHUP; |
| 465 | sigemptyset(&sa_hup.sa_mask); |
| 466 | sa_hup.sa_flags = 0; |
| 467 | sigaction(SIGHUP, &sa_hup, nullptr); |
| 468 | |
| 469 | // Initialize elliptic curve code |
| 470 | ECC_Start(); |
| 471 | globalVerifyHandle.reset(new ECCVerifyHandle()); |
| 472 | |
| 473 | // Sanity check |
| 474 | if (!ECC_InitSanityCheck()) |
| 475 | return fprintf(stderr, "Elliptic curve cryptography sanity check failure. Aborting."); |
| 476 | |
| 477 | //register wasm routes for native inline_transaction dispatch |
| 478 | wasm_load_native_modules_and_register_routes(); |
nothing calls this directly
no test coverage detected