From 4f172ab6747de137fc8c1ead27290b4c27816ad5 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 29 Jan 2021 13:06:59 +1000 Subject: [PATCH] Require Inbound setup handlers to provide a result Rather than having them default to `Ok(())`, which is incorrect for some error handlers. --- zebrad/src/components/inbound.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zebrad/src/components/inbound.rs b/zebrad/src/components/inbound.rs index 24bafee902b..2e66a1c9af2 100644 --- a/zebrad/src/components/inbound.rs +++ b/zebrad/src/components/inbound.rs @@ -150,7 +150,9 @@ impl Service for Inbound { // and reporting unreadiness might cause unwanted load-shedding, since // the load-shed middleware is unable to distinguish being unready due // to load from being unready while waiting on setup. - let mut result = Ok(()); + + // Every network_setup state handler must provide a result + let result; self.network_setup = match self.take_setup() { Setup::AwaitingNetwork { @@ -163,6 +165,7 @@ impl Service for Inbound { Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT), self.state.clone(), )); + result = Ok(()); Setup::Initialized { address_book, downloads, @@ -170,6 +173,7 @@ impl Service for Inbound { } Err(TryRecvError::Empty) => { // There's no setup data yet, so keep waiting for it + result = Ok(()); Setup::AwaitingNetwork { network_setup, verifier, @@ -196,6 +200,8 @@ impl Service for Inbound { mut downloads, } => { while let Poll::Ready(Some(_)) = downloads.as_mut().poll_next(cx) {} + + result = Ok(()); Setup::Initialized { address_book, downloads,