/// Insert a vote with given value into the graph at given hash and number.
Insert a vote with given value into the graph at given hash and number.
Insert a vote with given value into the graph at given hash and number .
pub fn insert<C: Chain<H, N>, W>(
		&mut self,
		hash: H,
		number: N,
		vote: W,
		chain: &C,
	) -> Result<(), Error>
	where
		V: for<'a> AddAssign<&'a W>,
	{
		if let Some(containing) = self.find_containing_nodes(hash.clone(), number) {
			if containing.is_empty() {
				self.append(hash.clone(), number, chain)?;
			} else {
				self.introduce_branch(containing, hash.clone(), number);
			}
		} else {
			// this entry already exists
		}
		// update cumulative vote data.
		// NOTE: below this point, there always exists a node with the given hash and number.
		let mut inspecting_hash = hash;
		loop {
			let active_entry = self
				.entries
				.get_mut(&inspecting_hash)
				.expect("vote-node and its ancestry always exist after initial phase; qed");
			active_entry.cumulative_vote += &vote;
			match active_entry.ancestor_node() {
				Some(parent) => inspecting_hash = parent,
				None => break,
			}
		}
		Ok(())
	}
pub fn insert < C : Chain < H , N > , W > ( & mut self , hash : H , number : N , vote : W , chain : & C , ) -> Result < ( ) , Error > where V : for < ' a > AddAssign < & ' a W > , { if let Some ( containing ) = self . find_containing_nodes ( hash . clone ( ) , number ) { if containing . is_empty ( ) { self . append ( hash . clone ( ) , number , chain ) ? ; } else { self . introduce_branch ( containing , hash . clone ( ) , number ) ; } } else { // this entry already exists } // update cumulative vote data. // NOTE: below this point, there always exists a node with the given hash and number. let mut inspecting_hash = hash ; loop { let active_entry = self . entries . get_mut ( & inspecting_hash ) . expect ( " " ) ; active_entry . cumulative_vote += & vote ; match active_entry . ancestor_node ( ) { Some ( parent ) => inspecting_hash = parent , None => break , } } Ok ( ( ) ) }
Insert a vote with given value into the graph at given hash and number.
Insert a vote with given value into the graph at given hash and number .
&mut self
hash
H
number
N
vote
W
chain
&C