Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Don't search for authority set change block if delay is zero (#4076)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar authored and andresilva committed Nov 10, 2019
1 parent 6aa8551 commit db7657a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/finality-grandpa/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use fg_primitives::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog};
use sr_primitives::Justification;
use sr_primitives::generic::{BlockId, OpaqueDigestItemId};
use sr_primitives::traits::{
Block as BlockT, DigestFor, Header as HeaderT, NumberFor,
Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero,
};
use primitives::{H256, Blake2Hasher};

Expand Down Expand Up @@ -97,10 +97,14 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, SC> JustificationImport<Block>
pending_change.effective_number() > chain_info.finalized_number &&
pending_change.effective_number() <= chain_info.best_number
{
let effective_block_hash = self.select_chain.finality_target(
pending_change.canon_hash,
Some(pending_change.effective_number()),
);
let effective_block_hash = if !pending_change.delay.is_zero() {
self.select_chain.finality_target(
pending_change.canon_hash,
Some(pending_change.effective_number()),
)
} else {
Ok(Some(pending_change.canon_hash))
};

if let Ok(Some(hash)) = effective_block_hash {
if let Ok(Some(header)) = self.inner.header(&BlockId::Hash(hash)) {
Expand Down

0 comments on commit db7657a

Please sign in to comment.