Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Errors if slot_duration is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton committed Jun 19, 2020
1 parent cdc3fe9 commit a9e9820
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl Config {
C: AuxStore + ProvideRuntimeApi<B>, C::Api: BabeApi<B, Error = sp_blockchain::Error>,
{
trace!(target: "babe", "Getting slot duration");
match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| {
let config = match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| {
let has_api_v1 = a.has_api_with::<dyn BabeApi<B, Error = sp_blockchain::Error>, _>(
&b, |v| v == 1,
)?;
Expand All @@ -310,7 +310,15 @@ impl Config {
warn!(target: "babe", "Failed to get slot duration");
Err(s)
}
}?;

if config.slot_duration == 0 {
return Err(sp_blockchain::Error::Msg(
"Invalid value for slot_duration: the value must be greater than 0.".to_string(),
))
}

Ok(config)
}
}

Expand Down

0 comments on commit a9e9820

Please sign in to comment.