pub fn search_best_before<S: Storage<Block, T>>(
		&self,
		storage: &S,
		block: NumberFor<Block>,
		require_value: bool,
	) -> ClientResult<Option<(Entry<Block, T>, Option<ComplexBlockId<Block>>)>> {
		// we're looking for the best value
		let mut next = None;
		let mut current = self.valid_from.clone();
		if block >= self.valid_from.number {
			let value = if require_value { self.value.clone() } else { None };
			return Ok(Some((Entry { valid_from: current, value }, next)));
		}

		// else - travel back in time
		loop {
			let entry = storage.require_entry(&current)?;
			if block >= current.number {
				return Ok(Some((Entry { valid_from: current, value: entry.value }, next)));
			}

			next = Some(current);
			current = match entry.prev_valid_from {
				Some(prev_valid_from) => prev_valid_from,
				None => return Ok(None),
			};
		}
	}
/// Searches the list, ending with THIS entry for the best entry preceeding (or at)
/// given block number.
/// If the entry is found, result is the entry and the block id of next entry (if exists).
/// NOTE that this function does not check that the passed block is actually linked to
/// the blocks it found.
Searches the list, ending with THIS entry for the best entry preceeding (or at)
given block number.
If the entry is found, result is the entry and the block id of next entry (if exists).
NOTE that this function does not check that the passed block is actually linked to
the blocks it found.
Searches the list ending with THIS entry for the best entry preceeding ( or at ) given block number . If the entry is found result is the entry and the block id of next entry ( if exists ) . NOTE that this function does not check that the passed block is actually linked to the blocks it found .
pub fn search_best_before<S: Storage<Block, T>>(
		&self,
		storage: &S,
		block: NumberFor<Block>,
		require_value: bool,
	) -> ClientResult<Option<(Entry<Block, T>, Option<ComplexBlockId<Block>>)>> {
		// we're looking for the best value
		let mut next = None;
		let mut current = self.valid_from.clone();
		if block >= self.valid_from.number {
			let value = if require_value { self.value.clone() } else { None };
			return Ok(Some((Entry { valid_from: current, value }, next)));
		}
		// else - travel back in time
		loop {
			let entry = storage.require_entry(&current)?;
			if block >= current.number {
				return Ok(Some((Entry { valid_from: current, value: entry.value }, next)));
			}
			next = Some(current);
			current = match entry.prev_valid_from {
				Some(prev_valid_from) => prev_valid_from,
				None => return Ok(None),
			};
		}
	}
pub fn search_best_before < S : Storage < Block , T > > ( & self , storage : & S , block : NumberFor < Block > , require_value : bool , ) -> ClientResult < Option < ( Entry < Block , T > , Option < ComplexBlockId < Block > > ) > > { // we're looking for the best value let mut next = None ; let mut current = self . valid_from . clone ( ) ; if block >= self . valid_from . number { let value = if require_value { self . value . clone ( ) } else { None } ; return Ok ( Some ( ( Entry { valid_from : current , value } , next ) ) ) ; } // else - travel back in time loop { let entry = storage . require_entry ( & current ) ? ; if block >= current . number { return Ok ( Some ( ( Entry { valid_from : current , value : entry . value } , next ) ) ) ; } next = Some ( current ) ; current = match entry . prev_valid_from { Some ( prev_valid_from ) => prev_valid_from , None => return Ok ( None ) , } ; } }
Searches the list, ending with THIS entry for the best entry preceeding (or at)
given block number.
Searches the list ending with THIS entry for the best entry preceeding ( or at ) given block number .
&self
storage
&S
block
NumberFor<Block>
require_value
bool
&self
storage
&S
block
NumberFor<Block>
require_value
bool