pub(crate) fn verify(&self, set_id: u64, voters: &VoterSet<AuthorityId>) -> Result<(), ClientError>
	where
		NumberFor<Block>: grandpa::BlockNumberOps,
	{
		use grandpa::Chain;

		let ancestry_chain = AncestryChain::<Block>::new(&self.votes_ancestries);

		match grandpa::validate_commit(
			&self.commit,
			voters,
			&ancestry_chain,
		) {
			Ok(Some(_)) => {},
			_ => {
				let msg = "invalid commit in grandpa justification".to_string();
				return Err(ClientErrorKind::BadJustification(msg).into());
			}
		}

		let mut visited_hashes = HashSet::new();
		for signed in self.commit.precommits.iter() {
			if let Err(_) = communication::check_message_sig::<Block>(
				&grandpa::Message::Precommit(signed.precommit.clone()),
				&signed.id,
				&signed.signature,
				self.round,
				set_id,
			) {
				return Err(ClientErrorKind::BadJustification(
					"invalid signature for precommit in grandpa justification".to_string()).into());
			}

			if self.commit.target_hash == signed.precommit.target_hash {
				continue;
			}

			match ancestry_chain.ancestry(self.commit.target_hash, signed.precommit.target_hash) {
				Ok(route) => {
					// ancestry starts from parent hash but the precommit target hash has been visited
					visited_hashes.insert(signed.precommit.target_hash);
					for hash in route {
						visited_hashes.insert(hash);
					}
				},
				_ => {
					return Err(ClientErrorKind::BadJustification(
						"invalid precommit ancestry proof in grandpa justification".to_string()).into());
				},
			}
		}

		let ancestry_hashes = self.votes_ancestries
			.iter()
			.map(|h: &Block::Header| h.hash())
			.collect();

		if visited_hashes != ancestry_hashes {
			return Err(ClientErrorKind::BadJustification(
				"invalid precommit ancestries in grandpa justification with unused headers".to_string()).into());
		}

		Ok(())
	}
/// Validate the commit and the votes' ancestry proofs.
Validate the commit and the votes' ancestry proofs.
Validate the commit and the votes ' ancestry proofs .
pub(crate) fn verify(&self, set_id: u64, voters: &VoterSet<AuthorityId>) -> Result<(), ClientError>
	where
		NumberFor<Block>: grandpa::BlockNumberOps,
	{
		use grandpa::Chain;
		let ancestry_chain = AncestryChain::<Block>::new(&self.votes_ancestries);
		match grandpa::validate_commit(
			&self.commit,
			voters,
			&ancestry_chain,
		) {
			Ok(Some(_)) => {},
			_ => {
				let msg = "invalid commit in grandpa justification".to_string();
				return Err(ClientErrorKind::BadJustification(msg).into());
			}
		}
		let mut visited_hashes = HashSet::new();
		for signed in self.commit.precommits.iter() {
			if let Err(_) = communication::check_message_sig::<Block>(
				&grandpa::Message::Precommit(signed.precommit.clone()),
				&signed.id,
				&signed.signature,
				self.round,
				set_id,
			) {
				return Err(ClientErrorKind::BadJustification(
					"invalid signature for precommit in grandpa justification".to_string()).into());
			}
			if self.commit.target_hash == signed.precommit.target_hash {
				continue;
			}
			match ancestry_chain.ancestry(self.commit.target_hash, signed.precommit.target_hash) {
				Ok(route) => {
					// ancestry starts from parent hash but the precommit target hash has been visited
					visited_hashes.insert(signed.precommit.target_hash);
					for hash in route {
						visited_hashes.insert(hash);
					}
				},
				_ => {
					return Err(ClientErrorKind::BadJustification(
						"invalid precommit ancestry proof in grandpa justification".to_string()).into());
				},
			}
		}
		let ancestry_hashes = self.votes_ancestries
			.iter()
			.map(|h: &Block::Header| h.hash())
			.collect();
		if visited_hashes != ancestry_hashes {
			return Err(ClientErrorKind::BadJustification(
				"invalid precommit ancestries in grandpa justification with unused headers".to_string()).into());
		}
		Ok(())
	}
pub ( crate ) fn verify ( & self , set_id : u64 , voters : & VoterSet < AuthorityId > ) -> Result < ( ) , ClientError > where NumberFor < Block > : grandpa :: BlockNumberOps , { use grandpa :: Chain ; let ancestry_chain = AncestryChain :: < Block > :: new ( & self . votes_ancestries ) ; match grandpa :: validate_commit ( & self . commit , voters , & ancestry_chain , ) { Ok ( Some ( _ ) ) => { } , _ => { let msg = " " . to_string ( ) ; return Err ( ClientErrorKind :: BadJustification ( msg ) . into ( ) ) ; } } let mut visited_hashes = HashSet :: new ( ) ; for signed in self . commit . precommits . iter ( ) { if let Err ( _ ) = communication :: check_message_sig :: < Block > ( & grandpa :: Message :: Precommit ( signed . precommit . clone ( ) ) , & signed . id , & signed . signature , self . round , set_id , ) { return Err ( ClientErrorKind :: BadJustification ( " " . to_string ( ) ) . into ( ) ) ; } if self . commit . target_hash == signed . precommit . target_hash { continue ; } match ancestry_chain . ancestry ( self . commit . target_hash , signed . precommit . target_hash ) { Ok ( route ) => { // ancestry starts from parent hash but the precommit target hash has been visited visited_hashes . insert ( signed . precommit . target_hash ) ; for hash in route { visited_hashes . insert ( hash ) ; } } , _ => { return Err ( ClientErrorKind :: BadJustification ( " " . to_string ( ) ) . into ( ) ) ; } , } } let ancestry_hashes = self . votes_ancestries . iter ( ) . map ( | h : & Block :: Header | h . hash ( ) ) . collect ( ) ; if visited_hashes != ancestry_hashes { return Err ( ClientErrorKind :: BadJustification ( " " . to_string ( ) ) . into ( ) ) ; } Ok ( ( ) ) }
Validate the commit and the votes' ancestry proofs.
Validate the commit and the votes ' ancestry proofs .
&self
set_id
u64
voters
&VoterSet<AuthorityId>
&self
set_id
u64
voters
&VoterSet<AuthorityId>