Skip to content
Snippets Groups Projects
Commit 2645659a authored by Cecile Tonglet's avatar Cecile Tonglet Committed by GitHub
Browse files

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

* Initial commit

Forked at: 252416d3


No parent branch.

* Errors if slot_duration is zero

* Errors if slot_duration is zero

* Revert "Errors if slot_duration is zero"

This reverts commit a9e9820e124571f73d3e498e969a74d01fd3fe96.

* Update client/consensus/slots/src/lib.rs

Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
parent bce6a426
No related merge requests found
......@@ -455,7 +455,7 @@ impl<T: Clone> SlotDuration<T> {
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> sp_blockchain::Result<T>,
T: SlotData + Encode + Decode + Debug,
{
match client.get_aux(T::SLOT_KEY)? {
let slot_duration = match client.get_aux(T::SLOT_KEY)? {
Some(v) => <T as codec::Decode>::decode(&mut &v[..])
.map(SlotDuration)
.map_err(|_| {
......@@ -479,7 +479,15 @@ impl<T: Clone> SlotDuration<T> {
Ok(SlotDuration(genesis_slot_duration))
}
}?;
if slot_duration.slot_duration() == 0 {
return Err(sp_blockchain::Error::Msg(
"Invalid value for slot_duration: the value must be greater than 0.".into(),
))
}
Ok(slot_duration)
}
/// Returns slot data value.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment