mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
More descriptive error message when invalid slot duration is used (#6430)
* Initial commit
Forked at: 252416d385
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: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user