MCPcopy Create free account
hub / github.com/LUX-Core/lux / StartNode

Function StartNode

src/net.cpp:1880–1964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1878}
1879
1880void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) {
1881 uiInterface.InitMessage(_("Loading addresses..."));
1882 // Load addresses for peers.dat
1883 int64_t nStart = GetTimeMillis();{
1884 CAddrDB adb;
1885 if (adb.Read(addrman))
1886 LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
1887 else {
1888 LogPrintf("Invalid or missing peers.dat; recreating\n");
1889 DumpAddresses();
1890 }
1891 }
1892
1893 //try to read stored banlist
1894 CBanDB bandb;
1895 banmap_t banmap;
1896 if (bandb.Read(banmap)) {
1897 CNode::SetBanned(banmap); // thread save setter
1898 CNode::SetBannedSetDirty(false); // no need to write down, just read data
1899 CNode::SweepBanned(); // sweep out unused entries
1900
1901 LogPrint("net", "Loaded %d banned node ips/subnets from banlist.dat %dms\n",
1902 banmap.size(), GetTimeMillis() - nStart);
1903 } else {
1904 LogPrintf("Invalid or missing banlist.dat; recreating\n");
1905 CNode::SetBannedSetDirty(true);
1906 DumpBanlist();
1907 }
1908
1909 fAddressesInitialized = true;
1910
1911 if (semOutbound == NULL) {
1912 // initialize semaphore
1913 int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
1914 semOutbound = new CSemaphore(nMaxOutbound);
1915 }
1916
1917 if (pnodeLocalHost == NULL)
1918 pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
1919
1920 Discover(threadGroup);
1921
1922 //
1923 // Start threads
1924 //
1925
1926 if (!GetBoolArg("-dnsseed", true))
1927 LogPrintf("DNS seeding disabled\n");
1928 else
1929 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed));
1930
1931 // Map ports with UPnP
1932 MapPort(GetBoolArg("-upnp", DEFAULT_UPNP));
1933
1934 // Send and receive from sockets, accept connections
1935 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler));
1936
1937 // Initiate outbound connections from -addnode

Callers 1

AppInit2Function · 0.85

Calls 14

_Function · 0.85
GetTimeMillisFunction · 0.85
DumpAddressesFunction · 0.85
LogPrintFunction · 0.85
DumpBanlistFunction · 0.85
DiscoverFunction · 0.85
GetBoolArgFunction · 0.85
MapPortFunction · 0.85
scheduleEveryMethod · 0.80
GenerateStakesMethod · 0.80
CAddressClass · 0.70
CServiceClass · 0.70

Tested by

no test coverage detected