| 2740 | } |
| 2741 | |
| 2742 | void CConnman::StopNodes() |
| 2743 | { |
| 2744 | if (fAddressesInitialized) { |
| 2745 | DumpAddresses(); |
| 2746 | fAddressesInitialized = false; |
| 2747 | |
| 2748 | if (m_use_addrman_outgoing) { |
| 2749 | // Anchor connections are only dumped during clean shutdown. |
| 2750 | std::vector<CAddress> anchors_to_dump = GetCurrentBlockRelayOnlyConns(); |
| 2751 | if (anchors_to_dump.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) { |
| 2752 | anchors_to_dump.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS); |
| 2753 | } |
| 2754 | DumpAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME, anchors_to_dump); |
| 2755 | } |
| 2756 | } |
| 2757 | |
| 2758 | // Delete peer connections. |
| 2759 | std::vector<CNode*> nodes; |
| 2760 | WITH_LOCK(m_nodes_mutex, nodes.swap(m_nodes)); |
| 2761 | for (CNode* pnode : nodes) { |
| 2762 | pnode->CloseSocketDisconnect(); |
| 2763 | DeleteNode(pnode); |
| 2764 | } |
| 2765 | |
| 2766 | for (CNode* pnode : m_nodes_disconnected) { |
| 2767 | DeleteNode(pnode); |
| 2768 | } |
| 2769 | m_nodes_disconnected.clear(); |
| 2770 | vhListenSocket.clear(); |
| 2771 | semOutbound.reset(); |
| 2772 | semAddnode.reset(); |
| 2773 | } |
| 2774 | |
| 2775 | void CConnman::DeleteNode(CNode* pnode) |
| 2776 | { |