fn split_query_storage_range(
		&self,
		from: Block::Hash,
		to: Option<Block::Hash>
	) -> Result<QueryStorageRange<Block>> {
		let to = self.unwrap_or_best(to)?;
		let from_hdr = self.client.header(&BlockId::hash(from))?;
		let to_hdr = self.client.header(&BlockId::hash(to))?;
		match (from_hdr, to_hdr) {
			(Some(ref from), Some(ref to)) if from.number() <= to.number() => {
				// check if we can get from `to` to `from` by going through parent_hashes.
				let from_number = *from.number();
				let blocks = {
					let mut blocks = vec![to.hash()];
					let mut last = to.clone();
					while *last.number() > from_number {
						if let Some(hdr) = self.client.header(&BlockId::hash(*last.parent_hash()))? {
							blocks.push(hdr.hash());
							last = hdr;
						} else {
							bail!(invalid_block_range(
								Some(from),
								Some(to),
								format!("Parent of {} ({}) not found", last.number(), last.hash()),
							))
						}
					}
					if last.hash() != from.hash() {
						bail!(invalid_block_range(
							Some(from),
							Some(to),
							format!("Expected to reach `from`, got {} ({})", last.number(), last.hash()),
						))
					}
					blocks.reverse();
					blocks
				};
				// check if we can filter blocks-with-changes from some (sub)range using changes tries
				let changes_trie_range = self.client.max_key_changes_range(from_number, BlockId::Hash(to.hash()))?;
				let filtered_range_begin = changes_trie_range.map(|(begin, _)| (begin - from_number).as_() as usize);
				let (unfiltered_range, filtered_range) = split_range(blocks.len(), filtered_range_begin);
				Ok(QueryStorageRange {
					hashes: blocks,
					first_number: from_number,
					unfiltered_range,
					filtered_range,
				})
			},
			(from, to) => bail!(
				invalid_block_range(from.as_ref(), to.as_ref(), "Invalid range or unknown block".into())
			),
		}
	}
/// Splits the `query_storage` block range into 'filtered' and 'unfiltered' subranges.
/// Blocks that contain changes within filtered subrange could be filtered using changes tries.
/// Blocks that contain changes within unfiltered subrange must be filtered manually.
Splits the `query_storage` block range into 'filtered' and 'unfiltered' subranges.
Blocks that contain changes within filtered subrange could be filtered using changes tries.
Blocks that contain changes within unfiltered subrange must be filtered manually.
Splits the ` query_storage ` block range into ' filtered ' and ' unfiltered ' subranges . Blocks that contain changes within filtered subrange could be filtered using changes tries . Blocks that contain changes within unfiltered subrange must be filtered manually .
fn split_query_storage_range(
		&self,
		from: Block::Hash,
		to: Option<Block::Hash>
	) -> Result<QueryStorageRange<Block>> {
		let to = self.unwrap_or_best(to)?;
		let from_hdr = self.client.header(&BlockId::hash(from))?;
		let to_hdr = self.client.header(&BlockId::hash(to))?;
		match (from_hdr, to_hdr) {
			(Some(ref from), Some(ref to)) if from.number() <= to.number() => {
				// check if we can get from `to` to `from` by going through parent_hashes.
				let from_number = *from.number();
				let blocks = {
					let mut blocks = vec![to.hash()];
					let mut last = to.clone();
					while *last.number() > from_number {
						if let Some(hdr) = self.client.header(&BlockId::hash(*last.parent_hash()))? {
							blocks.push(hdr.hash());
							last = hdr;
						} else {
							bail!(invalid_block_range(
								Some(from),
								Some(to),
								format!("Parent of {} ({}) not found", last.number(), last.hash()),
							))
						}
					}
					if last.hash() != from.hash() {
						bail!(invalid_block_range(
							Some(from),
							Some(to),
							format!("Expected to reach `from`, got {} ({})", last.number(), last.hash()),
						))
					}
					blocks.reverse();
					blocks
				};
				// check if we can filter blocks-with-changes from some (sub)range using changes tries
				let changes_trie_range = self.client.max_key_changes_range(from_number, BlockId::Hash(to.hash()))?;
				let filtered_range_begin = changes_trie_range.map(|(begin, _)| (begin - from_number).as_() as usize);
				let (unfiltered_range, filtered_range) = split_range(blocks.len(), filtered_range_begin);
				Ok(QueryStorageRange {
					hashes: blocks,
					first_number: from_number,
					unfiltered_range,
					filtered_range,
				})
			},
			(from, to) => bail!(
				invalid_block_range(from.as_ref(), to.as_ref(), "Invalid range or unknown block".into())
			),
		}
	}
fn split_query_storage_range ( & self , from : Block :: Hash , to : Option < Block :: Hash > ) -> Result < QueryStorageRange < Block > > { let to = self . unwrap_or_best ( to ) ? ; let from_hdr = self . client . header ( & BlockId :: hash ( from ) ) ? ; let to_hdr = self . client . header ( & BlockId :: hash ( to ) ) ? ; match ( from_hdr , to_hdr ) { ( Some ( ref from ) , Some ( ref to ) ) if from . number ( ) <= to . number ( ) => { // check if we can get from `to` to `from` by going through parent_hashes. let from_number = * from . number ( ) ; let blocks = { let mut blocks = vec ! [ to hash ( ) ] ; let mut last = to . clone ( ) ; while * last . number ( ) > from_number { if let Some ( hdr ) = self . client . header ( & BlockId :: hash ( * last . parent_hash ( ) ) ) ? { blocks . push ( hdr . hash ( ) ) ; last = hdr ; } else { bail ! ( invalid_block_range ( Some ( from ) Some ( to ) format ( " " last number ( ) last hash ( ) ) ) ) } } if last . hash ( ) != from . hash ( ) { bail ! ( invalid_block_range ( Some ( from ) Some ( to ) format ( " " last number ( ) last hash ( ) ) ) ) } blocks . reverse ( ) ; blocks } ; // check if we can filter blocks-with-changes from some (sub)range using changes tries let changes_trie_range = self . client . max_key_changes_range ( from_number , BlockId :: Hash ( to . hash ( ) ) ) ? ; let filtered_range_begin = changes_trie_range . map ( | ( begin , _ ) | ( begin - from_number ) . as_ ( ) as usize ) ; let ( unfiltered_range , filtered_range ) = split_range ( blocks . len ( ) , filtered_range_begin ) ; Ok ( QueryStorageRange { hashes : blocks , first_number : from_number , unfiltered_range , filtered_range , } ) } , ( from , to ) => bail ! ( invalid_block_range ( from as_ref ( ) to as_ref ( ) " " into ( ) ) ) , } }
Splits the `query_storage` block range into 'filtered' and 'unfiltered' subranges.
Splits the ` query_storage ` block range into ' filtered ' and ' unfiltered ' subranges .
&self
from
Block::Hash
to
Option<Block::Hash>
&self
from
Block::Hash
to
Option<Block::Hash>