Skip to content

Commit

Permalink
Use ServiceExt::oneshot in chain::init
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Feb 8, 2021
1 parent 17ee36c commit 1434016
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions zebra-consensus/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
pub async fn init<S>(
config: Config,
network: Network,
mut state_service: S,
state_service: S,
) -> Buffer<BoxService<Arc<Block>, block::Hash, VerifyChainError>, Arc<Block>>
where
S: Service<zs::Request, Response = zs::Response, Error = BoxError> + Send + Clone + 'static,
Expand All @@ -137,11 +137,13 @@ where
.expect("hardcoded checkpoint list extends past sapling activation")
};

// Correctness:
//
// We use `ServiceExt::oneshot` to make sure every `poll_ready` has a
// matching `call`. See #1593 for details.
let tip = match state_service
.ready_and()
.await
.unwrap()
.call(zs::Request::Tip)
.clone()
.oneshot(zs::Request::Tip)
.await
.unwrap()
{
Expand Down

0 comments on commit 1434016

Please sign in to comment.