Skip to content

Commit

Permalink
Require Inbound setup handlers to provide a result
Browse files Browse the repository at this point in the history
Rather than having them default to `Ok(())`, which is incorrect
for some error handlers.
  • Loading branch information
teor2345 committed Jan 29, 2021
1 parent 9bc8170 commit 4f172ab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zebrad/src/components/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ impl Service<zn::Request> 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 {
Expand All @@ -163,13 +165,15 @@ impl Service<zn::Request> for Inbound {
Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT),
self.state.clone(),
));
result = Ok(());
Setup::Initialized {
address_book,
downloads,
}
}
Err(TryRecvError::Empty) => {
// There's no setup data yet, so keep waiting for it
result = Ok(());
Setup::AwaitingNetwork {
network_setup,
verifier,
Expand All @@ -196,6 +200,8 @@ impl Service<zn::Request> for Inbound {
mut downloads,
} => {
while let Poll::Ready(Some(_)) = downloads.as_mut().poll_next(cx) {}

result = Ok(());
Setup::Initialized {
address_book,
downloads,
Expand Down

0 comments on commit 4f172ab

Please sign in to comment.