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

More descriptive error message when invalid slot duration is used #6430

Merged
merged 5 commits into from
Jun 19, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Invalid value for slot_duration: the value must be greater than 0.".to_string(),
"Invalid value for slot_duration: the value must be greater than 0.".into(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

))
}

Ok(config)
}
}

Expand Down