From 9778b0fec13c047a4c7f3ae425d044da26eadc81 Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Tue, 3 Aug 2021 09:26:29 -0700 Subject: [PATCH] [net_processing] Provide debug error if code assumptions change. Currently, this call to SetupAddressRelay will never return false because of the previous guard that returns early if the peer is not an inbound connection. Rather than implicitly relying on this guarantee, throw an error in the debug build if it ever changes. --- src/net_processing.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 005fe1bf0cb..754567420c3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3744,7 +3744,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, return; } - SetupAddressRelay(pfrom, *peer); + // Since this must be an inbound connection, SetupAddressRelay will + // never fail. + Assume(SetupAddressRelay(pfrom, *peer)); // Only send one GetAddr response per connection to reduce resource waste // and discourage addr stamping of INV announcements.