Skip to content

Commit

Permalink
Allow full node to verify author inherent (#192)
Browse files Browse the repository at this point in the history
* I think I found the issue.

* clean up

* unused variable

* Update pallets/author-inherent/src/lib.rs

Co-authored-by: Amar Singh <[email protected]>

Co-authored-by: Amar Singh <[email protected]>
  • Loading branch information
JoshOrndorff and 4meta5 authored Jan 20, 2021
1 parent 0ed2f6a commit e57bc03
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions pallets/author-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,15 @@ impl<T: Config> ProvideInherent for Module<T> {
Some(Call::set_author(author))
}

fn check_inherent(_call: &Self::Call, data: &InherentData) -> Result<(), Self::Error> {
let author_raw = data
.get_data::<InherentType>(&INHERENT_IDENTIFIER)
.expect("Gets and decodes authorship inherent data")
.ok_or_else(|| {
InherentError::Other(sp_runtime::RuntimeString::Borrowed(
"Decode authorship inherent data failed",
))
})?;
let author =
T::AccountId::decode(&mut &author_raw[..]).expect("Decodes author raw inherent data");
ensure!(
T::CanAuthor::can_author(&author),
InherentError::Other(sp_runtime::RuntimeString::Borrowed("Cannot Be Author"))
);
fn check_inherent(call: &Self::Call, _data: &InherentData) -> Result<(), Self::Error> {
// This if let should always be true. This is the only call that the inherent could make.
if let Self::Call::set_author(claimed_author) = call {
ensure!(
T::CanAuthor::can_author(&claimed_author),
InherentError::Other(sp_runtime::RuntimeString::Borrowed("Cannot Be Author"))
);
}

Ok(())
}
}

0 comments on commit e57bc03

Please sign in to comment.