pub fn encode<Block: BlockT, T: CacheItemT>(
		best_finalized_entry: Option<&Entry<Block, T>>,
		unfinalized: &[Fork<Block, T>],
		op: &CommitOperation<Block, T>
	) -> Vec<u8> {
		let mut finalized = best_finalized_entry.as_ref().map(|entry| &entry.valid_from);
		let mut unfinalized = unfinalized.iter().map(|fork| &fork.head().valid_from).collect::<Vec<_>>();

		match op {
			CommitOperation::AppendNewBlock(_, _) => (),
			CommitOperation::AppendNewEntry(index, ref entry) => {
				unfinalized[*index] = &entry.valid_from;
			},
			CommitOperation::AddNewFork(ref entry) => {
				unfinalized.push(&entry.valid_from);
			},
			CommitOperation::BlockFinalized(_, ref finalizing_entry, ref forks) => {
				finalized = finalizing_entry.as_ref().map(|entry| &entry.valid_from);
				for fork_index in forks.iter().rev() {
					unfinalized.remove(*fork_index);
				}
			},
		}

		(finalized, unfinalized).encode()
	}
/// Encode cache metadata 'applying' commit operation before encoding.
Encode cache metadata 'applying' commit operation before encoding.
Encode cache metadata ' applying ' commit operation before encoding .
pub fn encode<Block: BlockT, T: CacheItemT>(
		best_finalized_entry: Option<&Entry<Block, T>>,
		unfinalized: &[Fork<Block, T>],
		op: &CommitOperation<Block, T>
	) -> Vec<u8> {
		let mut finalized = best_finalized_entry.as_ref().map(|entry| &entry.valid_from);
		let mut unfinalized = unfinalized.iter().map(|fork| &fork.head().valid_from).collect::<Vec<_>>();
		match op {
			CommitOperation::AppendNewBlock(_, _) => (),
			CommitOperation::AppendNewEntry(index, ref entry) => {
				unfinalized[*index] = &entry.valid_from;
			},
			CommitOperation::AddNewFork(ref entry) => {
				unfinalized.push(&entry.valid_from);
			},
			CommitOperation::BlockFinalized(_, ref finalizing_entry, ref forks) => {
				finalized = finalizing_entry.as_ref().map(|entry| &entry.valid_from);
				for fork_index in forks.iter().rev() {
					unfinalized.remove(*fork_index);
				}
			},
		}
		(finalized, unfinalized).encode()
	}
pub fn encode < Block : BlockT , T : CacheItemT > ( best_finalized_entry : Option < & Entry < Block , T > > , unfinalized : & [ Fork < Block , T > ] , op : & CommitOperation < Block , T > ) -> Vec < u8 > { let mut finalized = best_finalized_entry . as_ref ( ) . map ( | entry | & entry . valid_from ) ; let mut unfinalized = unfinalized . iter ( ) . map ( | fork | & fork . head ( ) . valid_from ) . collect :: < Vec < _ > > ( ) ; match op { CommitOperation :: AppendNewBlock ( _ , _ ) => ( ) , CommitOperation :: AppendNewEntry ( index , ref entry ) => { unfinalized [ * index ] = & entry . valid_from ; } , CommitOperation :: AddNewFork ( ref entry ) => { unfinalized . push ( & entry . valid_from ) ; } , CommitOperation :: BlockFinalized ( _ , ref finalizing_entry , ref forks ) => { finalized = finalizing_entry . as_ref ( ) . map ( | entry | & entry . valid_from ) ; for fork_index in forks . iter ( ) . rev ( ) { unfinalized . remove ( * fork_index ) ; } } , } ( finalized , unfinalized ) . encode ( ) }
Encode cache metadata 'applying' commit operation before encoding.
Encode cache metadata ' applying ' commit operation before encoding .
best_finalized_entry
Option<&Entry<Block, T>>
unfinalized
&[Fork<Block, T>]
op
&CommitOperation<Block, T>
best_finalized_entry
Option<&Entry<Block, T>>
unfinalized
&[Fork<Block, T>]
op
&CommitOperation<Block, T>