Don't search for authority set change block if delay is zero
@@ -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};
@@ -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(
+ 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)) {
