MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / StopNodes

Method StopNodes

src/net.cpp:3709–3745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3707}
3708
3709void CConnman::StopNodes()
3710{
3711 AssertLockNotHeld(m_nodes_mutex);
3712 AssertLockNotHeld(m_reconnections_mutex);
3713
3714 if (fAddressesInitialized) {
3715 DumpAddresses();
3716 fAddressesInitialized = false;
3717
3718 if (m_use_addrman_outgoing) {
3719 // Anchor connections are only dumped during clean shutdown.
3720 std::vector<CAddress> anchors_to_dump = GetCurrentBlockRelayOnlyConns();
3721 if (anchors_to_dump.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
3722 anchors_to_dump.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
3723 }
3724 DumpAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME, anchors_to_dump);
3725 }
3726 }
3727
3728 // Delete peer connections.
3729 std::vector<CNode*> nodes;
3730 WITH_LOCK(m_nodes_mutex, nodes.swap(m_nodes));
3731 for (CNode* pnode : nodes) {
3732 LogDebug(BCLog::NET, "Stopping node, %s", pnode->DisconnectMsg());
3733 pnode->CloseSocketDisconnect();
3734 DeleteNode(pnode);
3735 }
3736
3737 for (CNode* pnode : m_nodes_disconnected) {
3738 DeleteNode(pnode);
3739 }
3740 m_nodes_disconnected.clear();
3741 WITH_LOCK(m_reconnections_mutex, m_reconnections.clear());
3742 vhListenSocket.clear();
3743 semOutbound.reset();
3744 semAddnode.reset();
3745}
3746
3747void CConnman::DeleteNode(CNode* pnode)
3748{

Callers 5

p2p_handshake.cppFile · 0.80
cmpctblock.cppFile · 0.80
ResetAndInitializeMethod · 0.80

Calls 9

DumpAnchorsFunction · 0.85
GetDataDirNetMethod · 0.80
DisconnectMsgMethod · 0.80
CloseSocketDisconnectMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
swapMethod · 0.45
clearMethod · 0.45
resetMethod · 0.45

Tested by 1

ResetAndInitializeMethod · 0.64