fn is_allowed(
		key: &[u8],
		parent_hash: &Option<B::Hash>,
		modifications:
		&VecDeque<BlockChanges<B::Header>>
	) -> bool
	{
		let mut parent = match *parent_hash {
			None => {
				trace!("Cache lookup skipped for {:?}: no parent hash", key);
				return false;
			}
			Some(ref parent) => parent,
		};
		if modifications.is_empty() {
			trace!("Cache lookup allowed for {:?}", key);
			return true;
		}
		// Ignore all storage modified in later blocks
		// Modifications contains block ordered by the number
		// We search for our parent in that list first and then for
		// all its parent until we hit the canonical block,
		// checking against all the intermediate modifications.
		for m in modifications {
			if &m.hash == parent {
				if m.is_canon {
					return true;
				}
				parent = &m.parent;
			}
			if m.storage.contains(key) {
				trace!("Cache lookup skipped for {:?}: modified in a later block", key);
				return false;
			}
		}
		trace!("Cache lookup skipped for {:?}: parent hash is unknown", key);
		false
	}
/// Check if the key can be returned from cache by matching current block parent hash against canonical
/// state and filtering out entries modified in later blocks.
Check if the key can be returned from cache by matching current block parent hash against canonical
state and filtering out entries modified in later blocks.
Check if the key can be returned from cache by matching current block parent hash against canonical state and filtering out entries modified in later blocks .
fn is_allowed(
		key: &[u8],
		parent_hash: &Option<B::Hash>,
		modifications:
		&VecDeque<BlockChanges<B::Header>>
	) -> bool
	{
		let mut parent = match *parent_hash {
			None => {
				trace!("Cache lookup skipped for {:?}: no parent hash", key);
				return false;
			}
			Some(ref parent) => parent,
		};
		if modifications.is_empty() {
			trace!("Cache lookup allowed for {:?}", key);
			return true;
		}
		// Ignore all storage modified in later blocks
		// Modifications contains block ordered by the number
		// We search for our parent in that list first and then for
		// all its parent until we hit the canonical block,
		// checking against all the intermediate modifications.
		for m in modifications {
			if &m.hash == parent {
				if m.is_canon {
					return true;
				}
				parent = &m.parent;
			}
			if m.storage.contains(key) {
				trace!("Cache lookup skipped for {:?}: modified in a later block", key);
				return false;
			}
		}
		trace!("Cache lookup skipped for {:?}: parent hash is unknown", key);
		false
	}
fn is_allowed ( key : & [ u8 ] , parent_hash : & Option < B :: Hash > , modifications : & VecDeque < BlockChanges < B :: Header > > ) -> bool { let mut parent = match * parent_hash { None => { trace ! ( " " key ) ; return false ; } Some ( ref parent ) => parent , } ; if modifications . is_empty ( ) { trace ! ( " " key ) ; return true ; } // Ignore all storage modified in later blocks // Modifications contains block ordered by the number // We search for our parent in that list first and then for // all its parent until we hit the canonical block, // checking against all the intermediate modifications. for m in modifications { if & m . hash == parent { if m . is_canon { return true ; } parent = & m . parent ; } if m . storage . contains ( key ) { trace ! ( " " key ) ; return false ; } } trace ! ( " " key ) ; false }
Check if the key can be returned from cache by matching current block parent hash against canonical
state and filtering out entries modified in later blocks.
Check if the key can be returned from cache by matching current block parent hash against canonical state and filtering out entries modified in later blocks .
key
&[u8]
parent_hash
&Option<B::Hash>
modifications
&VecDeque<BlockChanges<B::Header>>
key
&[u8]
parent_hash
&Option<B::Hash>
modifications
&VecDeque<BlockChanges<B::Header>>