mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
enable disputes (#3478)
* initial integration and migration code * fix tests * fix counting test * assume the current version on missing file * use SelectRelayChain * remove duplicate metric * Update node/service/src/lib.rs Co-authored-by: Robert Habermeier <rphmeier@gmail.com> * remove ApprovalCheckingVotingRule * address my concern * never mode for StagnantCheckInterval * REVERTME: some logs * w00t * it's ugly but it works * Revert "REVERTME: some logs" This reverts commit e210505a2e83e31c381394924500b69277bb042e. * it's handle, not handler * fix a few typos Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@ use polkadot_node_subsystem::{
|
||||
use kvdb::KeyValueDB;
|
||||
use parity_scale_codec::Error as CodecError;
|
||||
use futures::channel::oneshot;
|
||||
use futures::future::Either;
|
||||
use futures::prelude::*;
|
||||
|
||||
use std::time::{UNIX_EPOCH, Duration,SystemTime};
|
||||
@@ -244,7 +245,7 @@ impl Clock for SystemClock {
|
||||
|
||||
/// The interval, in seconds to check for stagnant blocks.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StagnantCheckInterval(Duration);
|
||||
pub struct StagnantCheckInterval(Option<Duration>);
|
||||
|
||||
impl Default for StagnantCheckInterval {
|
||||
fn default() -> Self {
|
||||
@@ -255,28 +256,37 @@ impl Default for StagnantCheckInterval {
|
||||
// between 2 validators is D + 5s.
|
||||
const DEFAULT_STAGNANT_CHECK_INTERVAL: Duration = Duration::from_secs(5);
|
||||
|
||||
StagnantCheckInterval(DEFAULT_STAGNANT_CHECK_INTERVAL)
|
||||
StagnantCheckInterval(Some(DEFAULT_STAGNANT_CHECK_INTERVAL))
|
||||
}
|
||||
}
|
||||
|
||||
impl StagnantCheckInterval {
|
||||
/// Create a new stagnant-check interval wrapping the given duration.
|
||||
pub fn new(interval: Duration) -> Self {
|
||||
StagnantCheckInterval(interval)
|
||||
StagnantCheckInterval(Some(interval))
|
||||
}
|
||||
|
||||
/// Create a `StagnantCheckInterval` which never triggers.
|
||||
pub fn never() -> Self {
|
||||
StagnantCheckInterval(None)
|
||||
}
|
||||
|
||||
fn timeout_stream(&self) -> impl Stream<Item = ()> {
|
||||
let interval = self.0;
|
||||
let mut delay = futures_timer::Delay::new(interval);
|
||||
match self.0 {
|
||||
Some(interval) => Either::Left({
|
||||
let mut delay = futures_timer::Delay::new(interval);
|
||||
|
||||
futures::stream::poll_fn(move |cx| {
|
||||
let poll = delay.poll_unpin(cx);
|
||||
if poll.is_ready() {
|
||||
delay.reset(interval)
|
||||
}
|
||||
futures::stream::poll_fn(move |cx| {
|
||||
let poll = delay.poll_unpin(cx);
|
||||
if poll.is_ready() {
|
||||
delay.reset(interval)
|
||||
}
|
||||
|
||||
poll.map(Some)
|
||||
})
|
||||
poll.map(Some)
|
||||
})
|
||||
}),
|
||||
None => Either::Right(futures::stream::pending()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user