Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
verifier supports both digest types
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshOrndorff committed Nov 3, 2021
1 parent aae5122 commit 1acb47f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions nimbus-consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,20 @@ where

debug!(target: crate::LOG_TARGET, "🪲 Signature according to verifier is {:?}", signature);

// Grab the digest from the runtime
//TODO use the trait. Maybe this code should move to the trait.
let consensus_digest = block_params.header
// Grab the author information from either the preruntime digest or the consensus digest
//TODO use the trait
let claimed_author = block_params.header
.digest()
.logs
.iter()
.find(|digest| {
.find_map(|digest| {
match *digest {
DigestItem::Consensus(id, _) if id == b"nmbs" => true,
_ => false,
DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()),
DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()),
_ => None,
}
})
.expect("A single consensus digest should be added by the runtime when executing the author inherent.");

let claimed_author = match *consensus_digest {
DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => author_id.clone(),
_ => panic!("Expected consensus digest to contains author id bytes"),
};
.expect("Expected one consensus or pre-runtime digest that contains author id bytes");

debug!(target: crate::LOG_TARGET, "🪲 Claimed Author according to verifier is {:?}", claimed_author);

Expand Down

0 comments on commit 1acb47f

Please sign in to comment.