fn check_new_change(&self, header: &Block::Header, hash: Block::Hash)
		-> Result<Option<PendingChange<Block::Hash, NumberFor<Block>>>, ConsensusError>
	{
		let at = BlockId::hash(*header.parent_hash());
		let digest = header.digest();

		let api = self.api.runtime_api();

		// check for forced change.
		{
			let maybe_change = api.grandpa_forced_change(
				&at,
				digest,
			);

			match maybe_change {
				Err(e) => match api.has_api_with::<GrandpaApi<Block>, _>(&at, |v| v >= 2) {
					Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()),
					Ok(true) => {
						// API version is high enough to support forced changes
						// but got error, so it is legitimate.
						return Err(ConsensusErrorKind::ClientImport(e.to_string()).into())
					},
					Ok(false) => {
						// API version isn't high enough to support forced changes
					},
				},
				Ok(None) => {},
				Ok(Some((median_last_finalized, change))) => return Ok(Some(PendingChange {
					next_authorities: change.next_authorities,
					delay: change.delay,
					canon_height: *header.number(),
					canon_hash: hash,
					delay_kind: DelayKind::Best { median_last_finalized },
				})),
			}
		}

		// check normal scheduled change.
		{
			let maybe_change = api.grandpa_pending_change(
				&at,
				digest,
			);

			match maybe_change {
				Err(e) => Err(ConsensusErrorKind::ClientImport(e.to_string()).into()),
				Ok(Some(change)) => Ok(Some(PendingChange {
					next_authorities: change.next_authorities,
					delay: change.delay,
					canon_height: *header.number(),
					canon_hash: hash,
					delay_kind: DelayKind::Finalized,
				})),
				Ok(None) => Ok(None),
			}
		}
	}
// check for a new authority set change.
check for a new authority set change.
check for a new authority set change .
fn check_new_change(&self, header: &Block::Header, hash: Block::Hash)
		-> Result<Option<PendingChange<Block::Hash, NumberFor<Block>>>, ConsensusError>
	{
		let at = BlockId::hash(*header.parent_hash());
		let digest = header.digest();
		let api = self.api.runtime_api();
		// check for forced change.
		{
			let maybe_change = api.grandpa_forced_change(
				&at,
				digest,
			);
			match maybe_change {
				Err(e) => match api.has_api_with::<GrandpaApi<Block>, _>(&at, |v| v >= 2) {
					Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()),
					Ok(true) => {
						// API version is high enough to support forced changes
						// but got error, so it is legitimate.
						return Err(ConsensusErrorKind::ClientImport(e.to_string()).into())
					},
					Ok(false) => {
						// API version isn't high enough to support forced changes
					},
				},
				Ok(None) => {},
				Ok(Some((median_last_finalized, change))) => return Ok(Some(PendingChange {
					next_authorities: change.next_authorities,
					delay: change.delay,
					canon_height: *header.number(),
					canon_hash: hash,
					delay_kind: DelayKind::Best { median_last_finalized },
				})),
			}
		}
		// check normal scheduled change.
		{
			let maybe_change = api.grandpa_pending_change(
				&at,
				digest,
			);
			match maybe_change {
				Err(e) => Err(ConsensusErrorKind::ClientImport(e.to_string()).into()),
				Ok(Some(change)) => Ok(Some(PendingChange {
					next_authorities: change.next_authorities,
					delay: change.delay,
					canon_height: *header.number(),
					canon_hash: hash,
					delay_kind: DelayKind::Finalized,
				})),
				Ok(None) => Ok(None),
			}
		}
	}
fn check_new_change ( & self , header : & Block :: Header , hash : Block :: Hash ) -> Result < Option < PendingChange < Block :: Hash , NumberFor < Block > > > , ConsensusError > { let at = BlockId :: hash ( * header . parent_hash ( ) ) ; let digest = header . digest ( ) ; let api = self . api . runtime_api ( ) ; // check for forced change. { let maybe_change = api . grandpa_forced_change ( & at , digest , ) ; match maybe_change { Err ( e ) => match api . has_api_with :: < GrandpaApi < Block > , _ > ( & at , | v | v >= 2 ) { Err ( e ) => return Err ( ConsensusErrorKind :: ClientImport ( e . to_string ( ) ) . into ( ) ) , Ok ( true ) => { // API version is high enough to support forced changes // but got error, so it is legitimate. return Err ( ConsensusErrorKind :: ClientImport ( e . to_string ( ) ) . into ( ) ) } , Ok ( false ) => { // API version isn't high enough to support forced changes } , } , Ok ( None ) => { } , Ok ( Some ( ( median_last_finalized , change ) ) ) => return Ok ( Some ( PendingChange { next_authorities : change . next_authorities , delay : change . delay , canon_height : * header . number ( ) , canon_hash : hash , delay_kind : DelayKind :: Best { median_last_finalized } , } ) ) , } } // check normal scheduled change. { let maybe_change = api . grandpa_pending_change ( & at , digest , ) ; match maybe_change { Err ( e ) => Err ( ConsensusErrorKind :: ClientImport ( e . to_string ( ) ) . into ( ) ) , Ok ( Some ( change ) ) => Ok ( Some ( PendingChange { next_authorities : change . next_authorities , delay : change . delay , canon_height : * header . number ( ) , canon_hash : hash , delay_kind : DelayKind :: Finalized , } ) ) , Ok ( None ) => Ok ( None ) , } } }
check for a new authority set change.
check for a new authority set change .
&self
header
&Block::Header
hash
Block::Hash
&self
header
&Block::Header
hash
Block::Hash