Skip to content

Commit

Permalink
[net] remove CConnman::AddNewAddresses
Browse files Browse the repository at this point in the history
It just forwards calls to CAddrMan::Add.
  • Loading branch information
jnewbery committed Mar 20, 2021
1 parent bcd7f30 commit 7c4cc67
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
5 changes: 0 additions & 5 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2635,11 +2635,6 @@ CConnman::~CConnman()
Stop();
}

bool CConnman::AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty)
{
return addrman.Add(vAddr, addrFrom, nTimePenalty);
}

std::vector<CAddress> CConnman::GetAddresses(size_t max_addresses, size_t max_pct)
{
std::vector<CAddress> addresses = addrman.GetAddr(max_addresses, max_pct);
Expand Down
1 change: 0 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ class CConnman
};

// Addrman functions
bool AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct);
/**
* Cache is used to minimize topology leaks, so it should
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
8 changes: 0 additions & 8 deletions src/test/fuzz/connman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ FUZZ_TARGET_INIT(connman, initialize_connman)
[&] {
random_string = fuzzed_data_provider.ConsumeRandomLengthString(64);
},
[&] {
std::vector<CAddress> 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<int32_t>());
},
[&] {
connman.AddNode(random_string);
},
Expand Down

0 comments on commit 7c4cc67

Please sign in to comment.