pub fn key_changes_proof_with_cht_size(
		&self,
		first: Block::Hash,
		last: Block::Hash,
		min: Block::Hash,
		max: Block::Hash,
		key: &StorageKey,
		cht_size: u64,
	) -> error::Result<ChangesProof<Block::Header>> {
		struct AccessedRootsRecorder<'a, Block: BlockT> {
			storage: &'a ChangesTrieStorage<Blake2Hasher>,
			min: u64,
			required_roots_proofs: Mutex<BTreeMap<NumberFor<Block>, H256>>,
		};

		impl<'a, Block: BlockT> ChangesTrieRootsStorage<Blake2Hasher> for AccessedRootsRecorder<'a, Block> {
			fn root(&self, anchor: &ChangesTrieAnchorBlockId<H256>, block: u64) -> Result<Option<H256>, String> {
				let root = self.storage.root(anchor, block)?;
				if block < self.min {
					if let Some(ref root) = root {
						self.required_roots_proofs.lock().insert(
							As::sa(block),
							root.clone()
						);
					}
				}
				Ok(root)
			}
		}

		impl<'a, Block: BlockT> ChangesTrieStorage<Blake2Hasher> for AccessedRootsRecorder<'a, Block> {
			fn get(&self, key: &H256, prefix: &[u8]) -> Result<Option<DBValue>, String> {
				self.storage.get(key, prefix)
			}
		}

		let (config, storage) = self.require_changes_trie()?;
		let min_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(min))?;

		let recording_storage = AccessedRootsRecorder::<Block> {
			storage,
			min: min_number.as_(),
			required_roots_proofs: Mutex::new(BTreeMap::new()),
		};

		let max_number = ::std::cmp::min(
			self.backend.blockchain().info()?.best_number,
			self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(max))?,
		);

		// fetch key changes proof
		let first_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(first))?.as_();
		let last_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(last))?.as_();
		let key_changes_proof = key_changes_proof::<_, Blake2Hasher>(
			&config,
			&recording_storage,
			first_number,
			&ChangesTrieAnchorBlockId {
				hash: convert_hash(&last),
				number: last_number,
			},
			max_number.as_(),
			&key.0
		)
		.map_err(|err| error::Error::from(error::ErrorKind::ChangesTrieAccessFailed(err)))?;

		// now gather proofs for all changes tries roots that were touched during key_changes_proof
		// execution AND are unknown (i.e. replaced with CHT) to the requester
		let roots = recording_storage.required_roots_proofs.into_inner();
		let roots_proof = self.changes_trie_roots_proof(cht_size, roots.keys().cloned())?;

		Ok(ChangesProof {
			max_block: max_number,
			proof: key_changes_proof,
			roots: roots.into_iter().map(|(n, h)| (n, convert_hash(&h))).collect(),
			roots_proof,
		})
	}
/// Does the same work as `key_changes_proof`, but assumes that CHTs are of passed size.
Does the same work as `key_changes_proof`, but assumes that CHTs are of passed size.
Does the same work as ` key_changes_proof ` but assumes that CHTs are of passed size .
pub fn key_changes_proof_with_cht_size(
		&self,
		first: Block::Hash,
		last: Block::Hash,
		min: Block::Hash,
		max: Block::Hash,
		key: &StorageKey,
		cht_size: u64,
	) -> error::Result<ChangesProof<Block::Header>> {
		struct AccessedRootsRecorder<'a, Block: BlockT> {
			storage: &'a ChangesTrieStorage<Blake2Hasher>,
			min: u64,
			required_roots_proofs: Mutex<BTreeMap<NumberFor<Block>, H256>>,
		};
		impl<'a, Block: BlockT> ChangesTrieRootsStorage<Blake2Hasher> for AccessedRootsRecorder<'a, Block> {
			fn root(&self, anchor: &ChangesTrieAnchorBlockId<H256>, block: u64) -> Result<Option<H256>, String> {
				let root = self.storage.root(anchor, block)?;
				if block < self.min {
					if let Some(ref root) = root {
						self.required_roots_proofs.lock().insert(
							As::sa(block),
							root.clone()
						);
					}
				}
				Ok(root)
			}
		}
		impl<'a, Block: BlockT> ChangesTrieStorage<Blake2Hasher> for AccessedRootsRecorder<'a, Block> {
			fn get(&self, key: &H256, prefix: &[u8]) -> Result<Option<DBValue>, String> {
				self.storage.get(key, prefix)
			}
		}
		let (config, storage) = self.require_changes_trie()?;
		let min_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(min))?;
		let recording_storage = AccessedRootsRecorder::<Block> {
			storage,
			min: min_number.as_(),
			required_roots_proofs: Mutex::new(BTreeMap::new()),
		};
		let max_number = ::std::cmp::min(
			self.backend.blockchain().info()?.best_number,
			self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(max))?,
		);
		// fetch key changes proof
		let first_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(first))?.as_();
		let last_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(last))?.as_();
		let key_changes_proof = key_changes_proof::<_, Blake2Hasher>(
			&config,
			&recording_storage,
			first_number,
			&ChangesTrieAnchorBlockId {
				hash: convert_hash(&last),
				number: last_number,
			},
			max_number.as_(),
			&key.0
		)
		.map_err(|err| error::Error::from(error::ErrorKind::ChangesTrieAccessFailed(err)))?;
		// now gather proofs for all changes tries roots that were touched during key_changes_proof
		// execution AND are unknown (i.e. replaced with CHT) to the requester
		let roots = recording_storage.required_roots_proofs.into_inner();
		let roots_proof = self.changes_trie_roots_proof(cht_size, roots.keys().cloned())?;
		Ok(ChangesProof {
			max_block: max_number,
			proof: key_changes_proof,
			roots: roots.into_iter().map(|(n, h)| (n, convert_hash(&h))).collect(),
			roots_proof,
		})
	}
pub fn key_changes_proof_with_cht_size ( & self , first : Block :: Hash , last : Block :: Hash , min : Block :: Hash , max : Block :: Hash , key : & StorageKey , cht_size : u64 , ) -> error :: Result < ChangesProof < Block :: Header > > { struct AccessedRootsRecorder < ' a , Block : BlockT > { storage : & ' a ChangesTrieStorage < Blake2Hasher > , min : u64 , required_roots_proofs : Mutex < BTreeMap < NumberFor < Block > , H256 > > , } ; impl < ' a , Block : BlockT > ChangesTrieRootsStorage < Blake2Hasher > for AccessedRootsRecorder < ' a , Block > { fn root ( & self , anchor : & ChangesTrieAnchorBlockId < H256 > , block : u64 ) -> Result < Option < H256 > , String > { let root = self . storage . root ( anchor , block ) ? ; if block < self . min { if let Some ( ref root ) = root { self . required_roots_proofs . lock ( ) . insert ( As :: sa ( block ) , root . clone ( ) ) ; } } Ok ( root ) } } impl < ' a , Block : BlockT > ChangesTrieStorage < Blake2Hasher > for AccessedRootsRecorder < ' a , Block > { fn get ( & self , key : & H256 , prefix : & [ u8 ] ) -> Result < Option < DBValue > , String > { self . storage . get ( key , prefix ) } } let ( config , storage ) = self . require_changes_trie ( ) ? ; let min_number = self . backend . blockchain ( ) . expect_block_number_from_id ( & BlockId :: Hash ( min ) ) ? ; let recording_storage = AccessedRootsRecorder :: < Block > { storage , min : min_number . as_ ( ) , required_roots_proofs : Mutex :: new ( BTreeMap :: new ( ) ) , } ; let max_number = :: std :: cmp :: min ( self . backend . blockchain ( ) . info ( ) ? . best_number , self . backend . blockchain ( ) . expect_block_number_from_id ( & BlockId :: Hash ( max ) ) ? , ) ; // fetch key changes proof let first_number = self . backend . blockchain ( ) . expect_block_number_from_id ( & BlockId :: Hash ( first ) ) ? . as_ ( ) ; let last_number = self . backend . blockchain ( ) . expect_block_number_from_id ( & BlockId :: Hash ( last ) ) ? . as_ ( ) ; let key_changes_proof = key_changes_proof :: < _ , Blake2Hasher > ( & config , & recording_storage , first_number , & ChangesTrieAnchorBlockId { hash : convert_hash ( & last ) , number : last_number , } , max_number . as_ ( ) , & key . 0 ) . map_err ( | err | error :: Error :: from ( error :: ErrorKind :: ChangesTrieAccessFailed ( err ) ) ) ? ; // now gather proofs for all changes tries roots that were touched during key_changes_proof // execution AND are unknown (i.e. replaced with CHT) to the requester let roots = recording_storage . required_roots_proofs . into_inner ( ) ; let roots_proof = self . changes_trie_roots_proof ( cht_size , roots . keys ( ) . cloned ( ) ) ? ; Ok ( ChangesProof { max_block : max_number , proof : key_changes_proof , roots : roots . into_iter ( ) . map ( | ( n , h ) | ( n , convert_hash ( & h ) ) ) . collect ( ) , roots_proof , } ) }
Does the same work as `key_changes_proof`, but assumes that CHTs are of passed size.
Does the same work as ` key_changes_proof ` but assumes that CHTs are of passed size .
&self
first
Block::Hash
last
Block::Hash
min
Block::Hash
max
Block::Hash
key
&StorageKey
cht_size
u64
&self
first
Block::Hash
last
Block::Hash
min
Block::Hash
max
Block::Hash
key
&StorageKey
cht_size
u64