Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
grandpa: use proper error types rather than strings
  • Loading branch information
andresilva committed May 7, 2020
commit a262a6a4c988beead1c0f6f9a4b69f45149b92f9
13 changes: 7 additions & 6 deletions frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ decl_error! {
ChangePending,
/// Cannot signal forced change so soon after last.
TooSoon,
/// A key ownership proof provided as part of an equivocation report is invalid.
InvalidKeyOwnershipProof,
/// A given equivocation report is valid but already previously reported.
DuplicateOffenceReport,
}
}

Expand Down Expand Up @@ -250,7 +254,7 @@ decl_module! {
T::KeyOwnerProofSystem::check_proof(
(fg_primitives::KEY_TYPE, equivocation_proof.offender().clone()),
key_owner_proof,
).ok_or("Invalid key ownership proof.")?;
).ok_or(Error::<T>::InvalidKeyOwnershipProof)?;

// the set id and round when the offence happened
let set_id = equivocation_proof.set_id();
Expand All @@ -266,7 +270,7 @@ decl_module! {
set_id,
round,
),
).map_err(|_| "Duplicate offence report.")?;
).map_err(|_| Error::<T>::DuplicateOffenceReport)?;
}

fn on_finalize(block_number: T::BlockNumber) {
Expand Down Expand Up @@ -455,10 +459,7 @@ impl<T: Trait> Module<T> {
equivocation_proof: EquivocationProof<T::Hash, T::BlockNumber>,
key_owner_proof: T::KeyOwnerProof,
) -> Option<()> {
T::HandleEquivocation::submit_equivocation_report(equivocation_proof, key_owner_proof)
.ok()?;

Some(())
T::HandleEquivocation::submit_equivocation_report(equivocation_proof, key_owner_proof).ok()
}
}

Expand Down