mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
Stop authoring blocks when offline (#1655)
* Don't author blocks when offline * Increased canonicalization delay * Fixed test
This commit is contained in:
committed by
Gav Wood
parent
2155e44e13
commit
641bb7cb46
@@ -433,7 +433,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
|
||||
debug!(target: "sync", "{} clogging messages:", clogging_messages.len());
|
||||
for msg_bytes in clogging_messages {
|
||||
for msg_bytes in clogging_messages.take(5) {
|
||||
if let Some(msg) = <Message<B> as Decode>::decode(&mut Cursor::new(msg_bytes)) {
|
||||
debug!(target: "sync", "{:?}", msg);
|
||||
} else {
|
||||
|
||||
@@ -234,6 +234,9 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> ::consensus::
|
||||
fn is_major_syncing(&self) -> bool {
|
||||
self.handler.sync().read().status().is_major_syncing()
|
||||
}
|
||||
fn is_offline(&self) -> bool {
|
||||
self.handler.sync().read().status().is_offline()
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H:ExHashT> Drop for Service<B, S, H> {
|
||||
|
||||
@@ -263,6 +263,8 @@ pub struct Status<B: BlockT> {
|
||||
pub state: SyncState,
|
||||
/// Target sync block number.
|
||||
pub best_seen_block: Option<NumberFor<B>>,
|
||||
/// Number of peers participating in syncing.
|
||||
pub num_peers: u32,
|
||||
}
|
||||
|
||||
impl<B: BlockT> Status<B> {
|
||||
@@ -274,6 +276,11 @@ impl<B: BlockT> Status<B> {
|
||||
SyncState::Downloading => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Are we all alone?
|
||||
pub fn is_offline(&self) -> bool {
|
||||
self.num_peers == 0
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> ChainSync<B> {
|
||||
@@ -315,6 +322,7 @@ impl<B: BlockT> ChainSync<B> {
|
||||
Status {
|
||||
state: state,
|
||||
best_seen_block: best_seen,
|
||||
num_peers: self.peers.len() as u32,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user