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

Function StartNode

src/net.cpp:1748–1810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1746}
1747
1748void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
1749{
1750 // Init network shapers
1751 receiveShaper.set(GetArg("-receiveburst", 0) * 1000, GetArg("-receiveavg", 0) * 1000);
1752 sendShaper.set(GetArg("-sendburst", 0) * 1000, GetArg("-sendavg", 0) * 1000);
1753
1754 uiInterface.InitMessage(_("Loading addresses..."));
1755 // Load addresses for peers.dat
1756 int64_t nStart = GetTimeMillis();
1757 {
1758 CAddrDB adb;
1759 if (adb.Read(addrman))
1760 LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
1761 else {
1762 addrman.Clear(); // Addrman can be in an inconsistent state after failure, reset it
1763 LogPrintf("Invalid or missing peers.dat; recreating\n");
1764 }
1765 }
1766 LogPrintf("Loaded %i addresses from peers.dat %dms\n",
1767 addrman.size(), GetTimeMillis() - nStart);
1768 fAddressesInitialized = true;
1769
1770 if (semOutbound == NULL) {
1771 // initialize semaphore
1772 int nMaxOutbound = std::min((MAX_OUTBOUND_CONNECTIONS + MAX_FEELER_CONNECTIONS), nMaxConnections);
1773 semOutbound = new CSemaphore(nMaxOutbound);
1774 }
1775
1776 if (pnodeLocalHost == NULL)
1777 pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
1778
1779 Discover(threadGroup);
1780
1781 //
1782 // Start threads
1783 //
1784
1785 if (!GetBoolArg("-dnsseed", true))
1786 LogPrintf("DNS seeding disabled\n");
1787 else
1788 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed));
1789
1790 // Map ports with UPnP
1791 MapPort(GetBoolArg("-upnp", DEFAULT_UPNP));
1792
1793 // Download or load data that's useful for prioritising traffic by IP address.
1794 InitIPGroups(&scheduler);
1795
1796 // Send and receive from sockets, accept connections
1797 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler));
1798
1799 // Initiate outbound connections from -addnode
1800 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "addcon", &ThreadOpenAddedConnections));
1801
1802 // Initiate outbound connections
1803 threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "opencon", &ThreadOpenConnections));
1804
1805 // Process messages

Callers 1

AppInit2Function · 0.85

Calls 14

GetArgFunction · 0.85
_Function · 0.85
GetTimeMillisFunction · 0.85
DiscoverFunction · 0.85
GetBoolArgFunction · 0.85
MapPortFunction · 0.85
InitIPGroupsFunction · 0.85
setMethod · 0.80
scheduleEveryMethod · 0.80
CAddressClass · 0.70
CServiceClass · 0.70
ReadMethod · 0.45

Tested by

no test coverage detected