From 34bcdfc6a65de906c65edccdd96fe15219081cd2 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Mon, 10 Oct 2022 15:02:59 -0300 Subject: p2p, refactor: return vector/optional in `Lookup` --- src/bench/addrman.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/bench') diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp index 8a5cab443f..f498071595 100644 --- a/src/bench/addrman.cpp +++ b/src/bench/addrman.cpp @@ -79,13 +79,6 @@ static CNetAddr ResolveIP(const std::string& ip) return addr; } -static CService ResolveService(const std::string& ip, uint16_t port = 0) -{ - CService serv; - Lookup(ip, serv, port, false); - return serv; -} - /* Benchmarks */ static void AddrManAdd(benchmark::Bench& bench) @@ -118,8 +111,8 @@ static void AddrManSelectFromAlmostEmpty(benchmark::Bench& bench) AddrMan addrman{EMPTY_NETGROUPMAN, /*deterministic=*/false, ADDRMAN_CONSISTENCY_CHECK_RATIO}; // Add one address to the new table - CService addr = ResolveService("250.3.1.1", 8333); - addrman.Add({CAddress(addr, NODE_NONE)}, ResolveService("250.3.1.1", 8333)); + CService addr = Lookup("250.3.1.1", 8333, false).value(); + addrman.Add({CAddress(addr, NODE_NONE)}, addr); bench.run([&] { (void)addrman.Select(); -- cgit v1.2.3 From 5c832c3820253affc65c0ed490e26e5b0a4d5c9b Mon Sep 17 00:00:00 2001 From: brunoerg Date: Tue, 11 Oct 2022 13:37:45 -0300 Subject: p2p, refactor: return `std::optional` in `LookupHost` --- src/bench/addrman.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/bench') diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp index f498071595..f044feebba 100644 --- a/src/bench/addrman.cpp +++ b/src/bench/addrman.cpp @@ -72,13 +72,6 @@ static void FillAddrMan(AddrMan& addrman) AddAddressesToAddrMan(addrman); } -static CNetAddr ResolveIP(const std::string& ip) -{ - CNetAddr addr; - LookupHost(ip, addr, false); - return addr; -} - /* Benchmarks */ static void AddrManAdd(benchmark::Bench& bench) @@ -128,7 +121,7 @@ static void AddrManSelectByNetwork(benchmark::Bench& bench) i2p_service.SetSpecial("udhdrtrcetjm5sxzskjyr5ztpeszydbh4dpl3pl4utgqqw2v4jna.b32.i2p"); CAddress i2p_address(i2p_service, NODE_NONE); i2p_address.nTime = Now(); - CNetAddr source = ResolveIP("252.2.2.2"); + const CNetAddr source{LookupHost("252.2.2.2", false).value()}; addrman.Add({i2p_address}, source); FillAddrMan(addrman); -- cgit v1.2.3