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

Don't search for authority search block if delay is zero #4076

Merged
merged 1 commit into from
Nov 10, 2019
Merged
Changes from all commits
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
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