mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 22:41:02 +00:00
error variant for failed deadline compute in validation worker (#383)
* error variant for failed deadline compute * fix compilation
This commit is contained in:
committed by
André Silva
parent
e6fb85a203
commit
742730c865
@@ -45,6 +45,8 @@ pub enum Error {
|
|||||||
/// Timer failed
|
/// Timer failed
|
||||||
#[display(fmt = "Timer failed: {}", _0)]
|
#[display(fmt = "Timer failed: {}", _0)]
|
||||||
Timer(std::io::Error),
|
Timer(std::io::Error),
|
||||||
|
#[display(fmt = "Failed to compute deadline of now + {:?}", _0)]
|
||||||
|
DeadlineComputeFailure(std::time::Duration),
|
||||||
/// Unable to dispatch agreement future
|
/// Unable to dispatch agreement future
|
||||||
#[display(fmt = "Unable to dispatch agreement future: {:?}", _0)]
|
#[display(fmt = "Unable to dispatch agreement future: {:?}", _0)]
|
||||||
Executor(futures::future::ExecuteErrorKind),
|
Executor(futures::future::ExecuteErrorKind),
|
||||||
|
|||||||
@@ -627,6 +627,14 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
|
|||||||
last_included: initial_included,
|
last_included: initial_included,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let deadline_diff = max_duration - max_duration / 3;
|
||||||
|
let deadline = match Instant::now().checked_add(deadline_diff) {
|
||||||
|
None => return Either::Right(
|
||||||
|
future::err(Error::DeadlineComputeFailure(deadline_diff)),
|
||||||
|
),
|
||||||
|
Some(d) => d,
|
||||||
|
};
|
||||||
|
|
||||||
Either::Left(CreateProposal {
|
Either::Left(CreateProposal {
|
||||||
parent_hash: self.parent_hash.clone(),
|
parent_hash: self.parent_hash.clone(),
|
||||||
parent_number: self.parent_number.clone(),
|
parent_number: self.parent_number.clone(),
|
||||||
@@ -639,7 +647,7 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
|
|||||||
inherent_data: Some(inherent_data),
|
inherent_data: Some(inherent_data),
|
||||||
inherent_digests,
|
inherent_digests,
|
||||||
// leave some time for the proposal finalisation
|
// leave some time for the proposal finalisation
|
||||||
deadline: Instant::now() + max_duration - max_duration / 3,
|
deadline,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user