pub fn adjust_base(&mut self, ancestry_proof: &[H]) {
		let new_hash = match ancestry_proof.last() {
			None => return, // empty -- nothing to do.
			Some(h) => h,
		};

		// not a valid ancestry proof. TODO: error?
		if ancestry_proof.len() > self.base_number.as_() {
			return
		}

		// hack because we can't convert usize -> N, only vice-versa.
		// hopefully LLVM can optimize.
		//
		// TODO: Add TryFrom to `BlockNumberOps`.
		let new_number = {
			let mut new_number = self.base_number;
			for _ in 0..ancestry_proof.len() {
				new_number = new_number - N::one();
			}
			new_number
		};

		let entry = {
			let old_entry =
				self.entries.get_mut(&self.base).expect("base hash entry always exists; qed");

			old_entry.ancestors.extend(ancestry_proof.iter().cloned());

			Entry {
				number: new_number,
				ancestors: Vec::new(),
				descendents: vec![self.base.clone()],
				cumulative_vote: old_entry.cumulative_vote.clone(),
			}
		};

		self.entries.insert(new_hash.clone(), entry);
		self.base = new_hash.clone();
		self.base_number = new_number;
	}
/// Adjust the base of the graph. The new base must be an ancestor of the
/// old base.
///
/// Provide an ancestry proof from the old base to the new. The proof
/// should be in reverse order from the old base's parent.
Adjust the base of the graph. The new base must be an ancestor of the
old base.

Provide an ancestry proof from the old base to the new. The proof
should be in reverse order from the old base's parent.
Adjust the base of the graph . The new base must be an ancestor of the old base . Provide an ancestry proof from the old base to the new . The proof should be in reverse order from the old base ' s parent .
pub fn adjust_base(&mut self, ancestry_proof: &[H]) {
		let new_hash = match ancestry_proof.last() {
			None => return, // empty -- nothing to do.
			Some(h) => h,
		};
		// not a valid ancestry proof. TODO: error?
		if ancestry_proof.len() > self.base_number.as_() {
			return
		}
		// hack because we can't convert usize -> N, only vice-versa.
		// hopefully LLVM can optimize.
		//
		// TODO: Add TryFrom to `BlockNumberOps`.
		let new_number = {
			let mut new_number = self.base_number;
			for _ in 0..ancestry_proof.len() {
				new_number = new_number - N::one();
			}
			new_number
		};
		let entry = {
			let old_entry =
				self.entries.get_mut(&self.base).expect("base hash entry always exists; qed");
			old_entry.ancestors.extend(ancestry_proof.iter().cloned());
			Entry {
				number: new_number,
				ancestors: Vec::new(),
				descendents: vec![self.base.clone()],
				cumulative_vote: old_entry.cumulative_vote.clone(),
			}
		};
		self.entries.insert(new_hash.clone(), entry);
		self.base = new_hash.clone();
		self.base_number = new_number;
	}
pub fn adjust_base ( & mut self , ancestry_proof : & [ H ] ) { let new_hash = match ancestry_proof . last ( ) { None => return , // empty -- nothing to do. Some ( h ) => h , } ; // not a valid ancestry proof. TODO: error? if ancestry_proof . len ( ) > self . base_number . as_ ( ) { return } // hack because we can't convert usize -> N, only vice-versa. // hopefully LLVM can optimize. // // TODO: Add TryFrom to `BlockNumberOps`. let new_number = { let mut new_number = self . base_number ; for _ in 0 .. ancestry_proof . len ( ) { new_number = new_number - N :: one ( ) ; } new_number } ; let entry = { let old_entry = self . entries . get_mut ( & self . base ) . expect ( " " ) ; old_entry . ancestors . extend ( ancestry_proof . iter ( ) . cloned ( ) ) ; Entry { number : new_number , ancestors : Vec :: new ( ) , descendents : vec ! [ self base clone ( ) ] , cumulative_vote : old_entry . cumulative_vote . clone ( ) , } } ; self . entries . insert ( new_hash . clone ( ) , entry ) ; self . base = new_hash . clone ( ) ; self . base_number = new_number ; }
Adjust the base of the graph.
Adjust the base of the graph .
&mut self
ancestry_proof
&[H]
&mut self
ancestry_proof
&[H]