Skip to content

Commit

Permalink
Remove the async block
Browse files Browse the repository at this point in the history
And make the code look like the `main` branch as much as possible.
  • Loading branch information
teor2345 committed Feb 8, 2021
1 parent 9c1b109 commit 89dd361
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions zebra-consensus/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod tests;

use displaydoc::Display;
use futures::FutureExt;
use futures::{FutureExt, TryFutureExt};
use std::{
future::Future,
pin::Pin,
Expand Down Expand Up @@ -83,26 +83,23 @@ where
}

fn call(&mut self, block: Arc<Block>) -> Self::Future {
let block_verifier = self.block_verifier.clone();
let checkpoint_verifier = self.checkpoint_verifier.clone();
let max_checkpoint_height = self.max_checkpoint_height;

async move {
match block.coinbase_height() {
Some(height) if (height <= max_checkpoint_height) => checkpoint_verifier
.oneshot(block)
.await
.map_err(VerifyChainError::Checkpoint),

// This also covers blocks with no height, which the block verifier
// will reject immediately.
_ => block_verifier
.oneshot(block)
.await
.map_err(VerifyChainError::Block),
}
match block.coinbase_height() {
Some(height) if (height <= self.max_checkpoint_height) => self
.checkpoint_verifier
.clone()
.oneshot(block)
.map_err(VerifyChainError::Checkpoint)
.boxed(),

// This also covers blocks with no height, which the block verifier
// will reject immediately.
_ => self
.block_verifier
.clone()
.oneshot(block)
.map_err(VerifyChainError::Block)
.boxed(),
}
.boxed()
}
}

Expand Down

0 comments on commit 89dd361

Please sign in to comment.