sc-consensus-beefy: fix on-demand async state machine (#13599)

`futures_util::pending!()` macro only yields to the event loop once,
resulting in many calls to the `OnDemandJustificationsEngine::next()`
made by the tokio reactor even though the on-demand-engine is idle.

Replace it with the correct `futures::future::pending::<()>()` function
which forever yields to the event loop, which is what we want when
the engine is idle.

Signed-off-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Adrian Catangiu
2023-03-14 16:52:53 +02:00
committed by GitHub
parent 9ced14e2de
commit 81a02cb7c4
3 changed files with 21 additions and 14 deletions
@@ -207,7 +207,7 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
pub async fn next(&mut self) -> Option<BeefyVersionedFinalityProof<B>> {
let (peer, req_info, resp) = match &mut self.state {
State::Idle => {
futures::pending!();
futures::future::pending::<()>().await;
return None
},
State::AwaitingResponse(peer, req_info, receiver) => {