MCPcopy Create free account
hub / github.com/ElementsProject/elements / Start

Method Start

src/net.cpp:2587–2684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2585}
2586
2587bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
2588{
2589 Init(connOptions);
2590
2591 if (fListen && !InitBinds(connOptions)) {
2592 if (m_client_interface) {
2593 m_client_interface->ThreadSafeMessageBox(
2594 _("Failed to listen on any port. Use -listen=0 if you want this."),
2595 "", CClientUIInterface::MSG_ERROR);
2596 }
2597 return false;
2598 }
2599
2600 Proxy i2p_sam;
2601 if (GetProxy(NET_I2P, i2p_sam)) {
2602 m_i2p_sam_session = std::make_unique<i2p::sam::Session>(gArgs.GetDataDirNet() / "i2p_private_key",
2603 i2p_sam.proxy, &interruptNet);
2604 }
2605
2606 for (const auto& strDest : connOptions.vSeedNodes) {
2607 AddAddrFetch(strDest);
2608 }
2609
2610 if (m_use_addrman_outgoing) {
2611 // Load addresses from anchors.dat
2612 m_anchors = ReadAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME);
2613 if (m_anchors.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
2614 m_anchors.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
2615 }
2616 LogPrintf("%i block-relay-only anchors will be tried for connections.\n", m_anchors.size());
2617 }
2618
2619 if (m_client_interface) {
2620 m_client_interface->InitMessage(_("Starting network threads…").translated);
2621 }
2622
2623 fAddressesInitialized = true;
2624
2625 if (semOutbound == nullptr) {
2626 // initialize semaphore
2627 semOutbound = std::make_unique<CSemaphore>(std::min(m_max_outbound, nMaxConnections));
2628 }
2629 if (semAddnode == nullptr) {
2630 // initialize semaphore
2631 semAddnode = std::make_unique<CSemaphore>(nMaxAddnode);
2632 }
2633
2634 //
2635 // Start threads
2636 //
2637 assert(m_msgproc);
2638 InterruptSocks5(false);
2639 interruptNet.reset();
2640 flagInterruptMsgProc = false;
2641
2642 {
2643 LOCK(mutexMsgProc);
2644 fMsgProcWake = false;

Callers 1

AppInitMainFunction · 0.45

Calls 14

_Function · 0.85
GetProxyFunction · 0.85
ReadAnchorsFunction · 0.85
InterruptSocks5Function · 0.85
ThreadSafeMessageBoxMethod · 0.80
InitMessageMethod · 0.80
GetBoolArgMethod · 0.80
scheduleEveryMethod · 0.80
InitClass · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected