MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FinalizeNode

Method FinalizeNode

src/net_processing.cpp:623–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) {
624 fUpdateConnectionTime = false;
625 LOCK(cs_main);
626 CNodeState *state = State(nodeid);
627 assert(state != nullptr);
628
629 if (state->fSyncStarted)
630 nSyncStarted--;
631
632 if (state->nMisbehavior == 0 && state->fCurrentlyConnected) {
633 fUpdateConnectionTime = true;
634 }
635
636 for (const QueuedBlock& entry : state->vBlocksInFlight) {
637 mapBlocksInFlight.erase(entry.hash);
638 }
639 EraseOrphansFor(nodeid);
640 nPreferredDownload -= state->fPreferredDownload;
641 nPeersWithValidatedDownloads -= (state->nBlocksInFlightValidHeaders != 0);
642 assert(nPeersWithValidatedDownloads >= 0);
643 g_outbound_peers_with_protect_from_disconnect -= state->m_chain_sync.m_protect;
644 assert(g_outbound_peers_with_protect_from_disconnect >= 0);
645
646 mapNodeState.erase(nodeid);
647
648 if (mapNodeState.empty()) {
649 // Do a consistency check after the last peer is removed.
650 assert(mapBlocksInFlight.empty());
651 assert(nPreferredDownload == 0);
652 assert(nPeersWithValidatedDownloads == 0);
653 assert(g_outbound_peers_with_protect_from_disconnect == 0);
654 }
655 LogPrint(BCLog::NET, "Cleared nodestate for peer=%d\n", nodeid);
656}
657
658bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
659 LOCK(cs_main);

Callers 2

DeleteNodeMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 4

EraseOrphansForFunction · 0.85
StateClass · 0.50
eraseMethod · 0.45
emptyMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64