Skip to content

Commit a27cba2

Browse files
committed
Error handling for autoshutdown of ex validators DMDcoin#322
+ typo fixes
1 parent f93430a commit a27cba2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

crates/ethcore/src/engines/hbbft/hbbft_state.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,19 @@ impl HbbftState {
228228
.ok()?;
229229

230230
if self.is_validator() {
231-
if client
232-
.as_full_client()
233-
.expect("full client")
234-
.is_major_syncing()
235-
{
236-
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://github.com/DMDcoin/diamond-node/issues/322.");
231+
let is_syncing = if let Some(full) = client.as_full_client() {
232+
full.is_major_syncing()
233+
} else {
234+
info!(target: "engine", "Node was a validator: cannot be determinated, because client is not a full client. (https://github.com/DMDcoin/diamond-node/issues/322.)");
235+
return Some(());
236+
};
237+
238+
if is_syncing {
239+
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined in https://github.com/DMDcoin/diamond-node/issues/322.");
237240
} else {
238241
info!(target: "engine", "Node was a validator, and became regular node. shutting down Node as defined in https://github.com/DMDcoin/diamond-node/issues/322.");
239-
// for unit tests no problem, demand shutddown wont to anything if its a unit test.
240-
// e2e tests needs adaption.
242+
// for unit tests no problem, demand shutddown won't to anything if its a unit test.
243+
// e2e tests needs adaptation.
241244
// this gracefully shuts down a node, if it was a validator before, but now it is not anymore.
242245
client.demand_shutdown();
243246
}

0 commit comments

Comments
 (0)