Skip to content

Commit f93430a

Browse files
committed
Node shutdown, if a validator becomes a regular node:
DMDcoin#322
1 parent 14129bf commit f93430a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,26 @@ impl HbbftState {
222222
}
223223

224224
if sks.is_none() {
225-
info!(target: "engine", "We are not part of the HoneyBadger validator set - running as regular node.");
225+
info!(target: "engine", "We are not part of the HoneyBadger validator set - Running as regular node.");
226226
peers_service
227227
.send_message(HbbftConnectToPeersMessage::DisconnectAllValidators)
228228
.ok()?;
229+
230+
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.");
237+
} else {
238+
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.
241+
// this gracefully shuts down a node, if it was a validator before, but now it is not anymore.
242+
client.demand_shutdown();
243+
}
244+
}
229245
return Some(());
230246
}
231247

0 commit comments

Comments
 (0)