From 7c4cc67c0c3c50df004ee53cac5b2884b7fbab29 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Fri, 23 Oct 2020 10:24:16 +0100 Subject: [PATCH] [net] remove CConnman::AddNewAddresses It just forwards calls to CAddrMan::Add. --- src/net.cpp | 5 ----- src/net.h | 1 - src/net_processing.cpp | 2 +- src/rpc/net.cpp | 6 +++--- src/test/fuzz/connman.cpp | 8 -------- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 0e5909612e..9553bbddfa 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2635,11 +2635,6 @@ CConnman::~CConnman() Stop(); } -bool CConnman::AddNewAddresses(const std::vector& vAddr, const CAddress& addrFrom, int64_t nTimePenalty) -{ - return addrman.Add(vAddr, addrFrom, nTimePenalty); -} - std::vector CConnman::GetAddresses(size_t max_addresses, size_t max_pct) { std::vector addresses = addrman.GetAddr(max_addresses, max_pct); diff --git a/src/net.h b/src/net.h index f2add667d2..820b680c6c 100644 --- a/src/net.h +++ b/src/net.h @@ -921,7 +921,6 @@ public: }; // Addrman functions - bool AddNewAddresses(const std::vector& vAddr, const CAddress& addrFrom, int64_t nTimePenalty = 0); std::vector GetAddresses(size_t max_addresses, size_t max_pct); /** * Cache is used to minimize topology leaks, so it should diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ff1e46eb67..4b91d86cfa 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2681,7 +2681,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, if (fReachable) vAddrOk.push_back(addr); } - m_connman.AddNewAddresses(vAddrOk, pfrom.addr, 2 * 60 * 60); + m_addrman.Add(vAddrOk, pfrom.addr, 2 * 60 * 60); if (vAddr.size() < 1000) pfrom.fGetAddr = false; if (pfrom.IsAddrFetchConn()) { diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index d4c1ab4b53..96533a50c8 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -907,8 +907,8 @@ static RPCHelpMan addpeeraddress() [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureNodeContext(request.context); - if (!node.connman) { - throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); + if (!node.addrman) { + throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Address manager functionality missing or disabled"); } UniValue obj(UniValue::VOBJ); @@ -925,7 +925,7 @@ static RPCHelpMan addpeeraddress() address.nTime = GetAdjustedTime(); // The source address is set equal to the address. This is equivalent to the peer // announcing itself. - if (!node.connman->AddNewAddresses({address}, address)) { + if (!node.addrman->Add(address, address)) { obj.pushKV("success", false); return obj; } diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp index dec580ea22..e07f25dedf 100644 --- a/src/test/fuzz/connman.cpp +++ b/src/test/fuzz/connman.cpp @@ -43,14 +43,6 @@ FUZZ_TARGET_INIT(connman, initialize_connman) [&] { random_string = fuzzed_data_provider.ConsumeRandomLengthString(64); }, - [&] { - std::vector addresses; - while (fuzzed_data_provider.ConsumeBool()) { - addresses.push_back(ConsumeAddress(fuzzed_data_provider)); - } - // Limit nTimePenalty to int32_t to avoid signed integer overflow - (void)connman.AddNewAddresses(addresses, ConsumeAddress(fuzzed_data_provider), fuzzed_data_provider.ConsumeIntegral()); - }, [&] { connman.AddNode(random_string); },