MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / StartNode

Function StartNode

src/net.cpp:1382–1425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380}
1381
1382void StartNode(boost::thread_group& threadGroup) {
1383 if (semOutbound == nullptr) {
1384 // initialize semaphore
1385 int32_t nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
1386 semOutbound = new CSemaphore(nMaxOutbound);
1387 }
1388
1389 if (pnodeLocalHost == nullptr)
1390 pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
1391
1392 Discover(threadGroup);
1393
1394 //
1395 // Start threads
1396 //
1397
1398 if (!SysCfg().GetBoolArg("-dnsseed", true)) {
1399 LogPrint(BCLog::INFO, "DNS seeding disabled\n");
1400 } else {
1401 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed));
1402 }
1403
1404#ifdef USE_UPNP
1405 // Map ports with UPnP
1406 MapPort(SysCfg().GetBoolArg("-upnp", USE_UPNP));
1407#endif
1408
1409 // Send and receive from sockets, accept connections
1410 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler));
1411
1412 // Initiate outbound connections from -addnode
1413 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "addcon", &ThreadOpenAddedConnections));
1414
1415 // Initiate outbound connections
1416 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "opencon", &ThreadOpenConnections));
1417
1418 // Process messages
1419 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "msghand", &ThreadMessageHandler));
1420
1421 // Dump network addresses
1422 threadGroup.create_thread(boost::bind(&LoopForever<void (*)()>, "dumpaddr", &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000));
1423
1424 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "post-ip", &ThreadPostNodeInfo));
1425}
1426
1427bool StopNode() {
1428 LogPrint(BCLog::INFO, "StopNode()\n");

Callers 1

AppInitFunction · 0.85

Calls 5

DiscoverFunction · 0.85
MapPortFunction · 0.85
GetBoolArgMethod · 0.80
CServiceClass · 0.70
CAddressClass · 0.50

Tested by

no test coverage detected