trait UpdateWith<T> {
    // Required methods
    fn update_chain_tip_with(
        &mut self,
        _: &T
    ) -> Result<(), ValidateContextError>;
    fn revert_chain_with(&mut self, _: &T, position: RevertPosition);
}
Expand description

Helper trait to organize inverse operations done on the Chain type.

Used to overload update and revert methods, based on the type of the argument, and the position of the removed block in the chain.

This trait was motivated by the length of the push, Chain::pop_root, and Chain::pop_tip functions, and fear that it would be easy to introduce bugs when updating them, unless the code was reorganized to keep related operations adjacent to each other.

Required Methods§

source

fn update_chain_tip_with(&mut self, _: &T) -> Result<(), ValidateContextError>

When T is added to the chain tip, update Chain cumulative data members to add data that are derived from T.

source

fn revert_chain_with(&mut self, _: &T, position: RevertPosition)

When T is removed from position in the chain, revert Chain cumulative data members to remove data that are derived from T.

Implementors§