Skip to content

Commit a9e9820

Browse files
committed
Errors if slot_duration is zero
1 parent cdc3fe9 commit a9e9820

File tree

1 file changed

+9
-1
lines changed
  • client/consensus/babe/src

1 file changed

+9
-1
lines changed

client/consensus/babe/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Config {
285285
C: AuxStore + ProvideRuntimeApi<B>, C::Api: BabeApi<B, Error = sp_blockchain::Error>,
286286
{
287287
trace!(target: "babe", "Getting slot duration");
288-
match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| {
288+
let config = match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| {
289289
let has_api_v1 = a.has_api_with::<dyn BabeApi<B, Error = sp_blockchain::Error>, _>(
290290
&b, |v| v == 1,
291291
)?;
@@ -310,7 +310,15 @@ impl Config {
310310
warn!(target: "babe", "Failed to get slot duration");
311311
Err(s)
312312
}
313+
}?;
314+
315+
if config.slot_duration == 0 {
316+
return Err(sp_blockchain::Error::Msg(
317+
"Invalid value for slot_duration: the value must be greater than 0.".to_string(),
318+
))
313319
}
320+
321+
Ok(config)
314322
}
315323
}
316324

0 commit comments

Comments
 (0)