fn check_changes_proof_with_cht_size(
		&self,
		request: &RemoteChangesRequest<B::Header>,
		remote_proof: ChangesProof<B::Header>,
		cht_size: u64,
	) -> ClientResult<Vec<(NumberFor<B>, u32)>>
		where
			H: Hasher,
			H::Out: Ord + HeapSizeOf,
	{
		// since we need roots of all changes tries for the range begin..max
		// => remote node can't use max block greater that one that we have passed
		if remote_proof.max_block > request.max_block.0 || remote_proof.max_block < request.last_block.0 {
			return Err(ClientErrorKind::ChangesTrieAccessFailed(format!(
				"Invalid max_block used by the remote node: {}. Local: {}..{}..{}",
				remote_proof.max_block, request.first_block.0, request.last_block.0, request.max_block.0,
			)).into());
		}

		// check if remote node has responded with extra changes trie roots proofs
		// all changes tries roots must be in range [request.first_block.0; request.tries_roots.0)
		let is_extra_first_root = remote_proof.roots.keys().next()
			.map(|first_root| *first_root < request.first_block.0
				|| *first_root >= request.tries_roots.0)
			.unwrap_or(false);
		let is_extra_last_root = remote_proof.roots.keys().next_back()
			.map(|last_root| *last_root >= request.tries_roots.0)
			.unwrap_or(false);
		if is_extra_first_root || is_extra_last_root {
			return Err(ClientErrorKind::ChangesTrieAccessFailed(format!(
				"Extra changes tries roots proofs provided by the remote node: [{:?}..{:?}]. Expected in range: [{}; {})",
				remote_proof.roots.keys().next(), remote_proof.roots.keys().next_back(),
				request.first_block.0, request.tries_roots.0,
			)).into());
		}

		// if request has been composed when some required headers were already pruned
		// => remote node has sent us CHT-based proof of required changes tries roots
		// => check that this proof is correct before proceeding with changes proof
		let remote_max_block = remote_proof.max_block;
		let remote_roots = remote_proof.roots;
		let remote_roots_proof = remote_proof.roots_proof;
		let remote_proof = remote_proof.proof;
		if !remote_roots.is_empty() {
			self.check_changes_tries_proof(
				cht_size,
				&remote_roots,
				remote_roots_proof,
			)?;
		}

		// and now check the key changes proof + get the changes
		key_changes_proof_check::<_, H>(
			&request.changes_trie_config,
			&RootsStorage {
				roots: (request.tries_roots.0, &request.tries_roots.2),
				prev_roots: remote_roots,
			},
			remote_proof,
			request.first_block.0.as_(),
			&ChangesTrieAnchorBlockId {
				hash: convert_hash(&request.last_block.1),
				number: request.last_block.0.as_(),
			},
			remote_max_block.as_(),
			&request.key)
		.map(|pairs| pairs.into_iter().map(|(b, x)| (As::sa(b), x)).collect())
		.map_err(|err| ClientErrorKind::ChangesTrieAccessFailed(err).into())
	}
/// Check remote changes query proof assuming that CHT-s are of given size.
Check remote changes query proof assuming that CHT-s are of given size.
Check remote changes query proof assuming that CHT - s are of given size .
fn check_changes_proof_with_cht_size(
		&self,
		request: &RemoteChangesRequest<B::Header>,
		remote_proof: ChangesProof<B::Header>,
		cht_size: u64,
	) -> ClientResult<Vec<(NumberFor<B>, u32)>>
		where
			H: Hasher,
			H::Out: Ord + HeapSizeOf,
	{
		// since we need roots of all changes tries for the range begin..max
		// => remote node can't use max block greater that one that we have passed
		if remote_proof.max_block > request.max_block.0 || remote_proof.max_block < request.last_block.0 {
			return Err(ClientErrorKind::ChangesTrieAccessFailed(format!(
				"Invalid max_block used by the remote node: {}. Local: {}..{}..{}",
				remote_proof.max_block, request.first_block.0, request.last_block.0, request.max_block.0,
			)).into());
		}
		// check if remote node has responded with extra changes trie roots proofs
		// all changes tries roots must be in range [request.first_block.0; request.tries_roots.0)
		let is_extra_first_root = remote_proof.roots.keys().next()
			.map(|first_root| *first_root < request.first_block.0
				|| *first_root >= request.tries_roots.0)
			.unwrap_or(false);
		let is_extra_last_root = remote_proof.roots.keys().next_back()
			.map(|last_root| *last_root >= request.tries_roots.0)
			.unwrap_or(false);
		if is_extra_first_root || is_extra_last_root {
			return Err(ClientErrorKind::ChangesTrieAccessFailed(format!(
				"Extra changes tries roots proofs provided by the remote node: [{:?}..{:?}]. Expected in range: [{}; {})",
				remote_proof.roots.keys().next(), remote_proof.roots.keys().next_back(),
				request.first_block.0, request.tries_roots.0,
			)).into());
		}
		// if request has been composed when some required headers were already pruned
		// => remote node has sent us CHT-based proof of required changes tries roots
		// => check that this proof is correct before proceeding with changes proof
		let remote_max_block = remote_proof.max_block;
		let remote_roots = remote_proof.roots;
		let remote_roots_proof = remote_proof.roots_proof;
		let remote_proof = remote_proof.proof;
		if !remote_roots.is_empty() {
			self.check_changes_tries_proof(
				cht_size,
				&remote_roots,
				remote_roots_proof,
			)?;
		}
		// and now check the key changes proof + get the changes
		key_changes_proof_check::<_, H>(
			&request.changes_trie_config,
			&RootsStorage {
				roots: (request.tries_roots.0, &request.tries_roots.2),
				prev_roots: remote_roots,
			},
			remote_proof,
			request.first_block.0.as_(),
			&ChangesTrieAnchorBlockId {
				hash: convert_hash(&request.last_block.1),
				number: request.last_block.0.as_(),
			},
			remote_max_block.as_(),
			&request.key)
		.map(|pairs| pairs.into_iter().map(|(b, x)| (As::sa(b), x)).collect())
		.map_err(|err| ClientErrorKind::ChangesTrieAccessFailed(err).into())
	}
fn check_changes_proof_with_cht_size ( & self , request : & RemoteChangesRequest < B :: Header > , remote_proof : ChangesProof < B :: Header > , cht_size : u64 , ) -> ClientResult < Vec < ( NumberFor < B > , u32 ) > > where H : Hasher , H :: Out : Ord + HeapSizeOf , { // since we need roots of all changes tries for the range begin..max // => remote node can't use max block greater that one that we have passed if remote_proof . max_block > request . max_block . 0 || remote_proof . max_block < request . last_block . 0 { return Err ( ClientErrorKind :: ChangesTrieAccessFailed ( format ! ( " " remote_proof max_block request first_block 0 request last_block 0 request max_block 0 ) ) . into ( ) ) ; } // check if remote node has responded with extra changes trie roots proofs // all changes tries roots must be in range [request.first_block.0; request.tries_roots.0) let is_extra_first_root = remote_proof . roots . keys ( ) . next ( ) . map ( | first_root | * first_root < request . first_block . 0 || * first_root >= request . tries_roots . 0 ) . unwrap_or ( false ) ; let is_extra_last_root = remote_proof . roots . keys ( ) . next_back ( ) . map ( | last_root | * last_root >= request . tries_roots . 0 ) . unwrap_or ( false ) ; if is_extra_first_root || is_extra_last_root { return Err ( ClientErrorKind :: ChangesTrieAccessFailed ( format ! ( " " remote_proof roots keys ( ) next ( ) remote_proof roots keys ( ) next_back ( ) request first_block 0 request tries_roots 0 ) ) . into ( ) ) ; } // if request has been composed when some required headers were already pruned // => remote node has sent us CHT-based proof of required changes tries roots // => check that this proof is correct before proceeding with changes proof let remote_max_block = remote_proof . max_block ; let remote_roots = remote_proof . roots ; let remote_roots_proof = remote_proof . roots_proof ; let remote_proof = remote_proof . proof ; if ! remote_roots . is_empty ( ) { self . check_changes_tries_proof ( cht_size , & remote_roots , remote_roots_proof , ) ? ; } // and now check the key changes proof + get the changes key_changes_proof_check :: < _ , H > ( & request . changes_trie_config , & RootsStorage { roots : ( request . tries_roots . 0 , & request . tries_roots . 2 ) , prev_roots : remote_roots , } , remote_proof , request . first_block . 0 . as_ ( ) , & ChangesTrieAnchorBlockId { hash : convert_hash ( & request . last_block . 1 ) , number : request . last_block . 0 . as_ ( ) , } , remote_max_block . as_ ( ) , & request . key ) . map ( | pairs | pairs . into_iter ( ) . map ( | ( b , x ) | ( As :: sa ( b ) , x ) ) . collect ( ) ) . map_err ( | err | ClientErrorKind :: ChangesTrieAccessFailed ( err ) . into ( ) ) }
Check remote changes query proof assuming that CHT-s are of given size.
Check remote changes query proof assuming that CHT - s are of given size .
&self
request
&RemoteChangesRequest<B::Header>
remote_proof
ChangesProof<B::Header>
cht_size
u64
&self
request
&RemoteChangesRequest<B::Header>
remote_proof
ChangesProof<B::Header>
cht_size
u64