fn traverse_on_apply(&self,
        update_cell: &Cell,
        old_cells: &HashMap<UInt256, Cell>,
        new_cells: &mut HashMap<UInt256, Cell>,
        merkle_depth: u8
    ) -> Result<Cell> {

        // We will recursively construct new skeleton for new cells 
        // and connect unchanged branches to it

        let mut new_cell = BuilderData::new();
        new_cell.set_type(update_cell.cell_type());

        let child_merkle_depth = if update_cell.is_merkle() { 
            merkle_depth + 1 
        } else { 
            merkle_depth 
        };

        // traverse references
        let mut child_mask = LevelMask::with_mask(0);
        for update_child in update_cell.clone_references().iter() {
            let new_child = match update_child.cell_type() {
                CellType::Ordinary | CellType::MerkleProof | CellType::MerkleUpdate => {
                    let new_child_hash = update_child.hash(child_merkle_depth as usize);
                    if let Some(c) = new_cells.get(&new_child_hash) {
                        c.clone()
                    } else {
                        let c = self.traverse_on_apply(update_child, old_cells, new_cells, child_merkle_depth)?;
                        new_cells.insert(new_child_hash, c.clone());
                        c
                    }
                },
                CellType::PrunedBranch => {
                    // if this pruned branch is related to current update
                    let mask = update_child.level_mask().mask();
                    if mask & (1 << child_merkle_depth) != 0 {
                        // connect branch from old bag instead pruned
                        let new_child_hash = Cell::hash(update_child, update_child.level() as usize - 1);
                        old_cells.get(&new_child_hash).unwrap().clone()
                    } else {
                        // else - just copy this cell (like an ordinary)
                        update_child.clone()
                    }
                },
                CellType::LibraryReference => {
                    unimplemented!() // TODO
                },
                _ => panic!("Unknown cell type!")
            };
            child_mask |= new_child.level_mask();
            new_cell.append_reference_cell(new_child);
        }

        new_cell.set_level_mask(if update_cell.is_merkle() {
            LevelMask::for_merkle_cell(child_mask)
        } else {
            child_mask
        });

        // Copy data from update to constructed cell
        new_cell.append_bytestring(&SliceData::from(update_cell)).unwrap();

        new_cell.into_cell()
    }
/// Recursive traverse merkle update tree while merkle update applying
/// `cell` ordinary cell from merkle update's new tree;
/// `old_cells` cells from old bag of cells;
Recursive traverse merkle update tree while merkle update applying
`cell` ordinary cell from merkle update's new tree;
`old_cells` cells from old bag of cells.
Recursive traverse merkle update tree while merkle update applying ` cell ` ordinary cell from merkle update ' s new tree ; ` old_cells ` cells from old bag of cells .
fn traverse_on_apply(&self,
        update_cell: &Cell,
        old_cells: &HashMap<UInt256, Cell>,
        new_cells: &mut HashMap<UInt256, Cell>,
        merkle_depth: u8
    ) -> Result<Cell> {
        // We will recursively construct new skeleton for new cells 
        // and connect unchanged branches to it
        let mut new_cell = BuilderData::new();
        new_cell.set_type(update_cell.cell_type());
        let child_merkle_depth = if update_cell.is_merkle() { 
            merkle_depth + 1 
        } else { 
            merkle_depth 
        };
        // traverse references
        let mut child_mask = LevelMask::with_mask(0);
        for update_child in update_cell.clone_references().iter() {
            let new_child = match update_child.cell_type() {
                CellType::Ordinary | CellType::MerkleProof | CellType::MerkleUpdate => {
                    let new_child_hash = update_child.hash(child_merkle_depth as usize);
                    if let Some(c) = new_cells.get(&new_child_hash) {
                        c.clone()
                    } else {
                        let c = self.traverse_on_apply(update_child, old_cells, new_cells, child_merkle_depth)?;
                        new_cells.insert(new_child_hash, c.clone());
                        c
                    }
                },
                CellType::PrunedBranch => {
                    // if this pruned branch is related to current update
                    let mask = update_child.level_mask().mask();
                    if mask & (1 << child_merkle_depth) != 0 {
                        // connect branch from old bag instead pruned
                        let new_child_hash = Cell::hash(update_child, update_child.level() as usize - 1);
                        old_cells.get(&new_child_hash).unwrap().clone()
                    } else {
                        // else - just copy this cell (like an ordinary)
                        update_child.clone()
                    }
                },
                CellType::LibraryReference => {
                    unimplemented!() // TODO
                },
                _ => panic!("Unknown cell type!")
            };
            child_mask |= new_child.level_mask();
            new_cell.append_reference_cell(new_child);
        }
        new_cell.set_level_mask(if update_cell.is_merkle() {
            LevelMask::for_merkle_cell(child_mask)
        } else {
            child_mask
        });
        // Copy data from update to constructed cell
        new_cell.append_bytestring(&SliceData::from(update_cell)).unwrap();
        new_cell.into_cell()
    }
fn traverse_on_apply ( & self , update_cell : & Cell , old_cells : & HashMap < UInt256 , Cell > , new_cells : & mut HashMap < UInt256 , Cell > , merkle_depth : u8 ) -> Result < Cell > { // We will recursively construct new skeleton for new cells  // and connect unchanged branches to it let mut new_cell = BuilderData :: new ( ) ; new_cell . set_type ( update_cell . cell_type ( ) ) ; let child_merkle_depth = if update_cell . is_merkle ( ) { merkle_depth + 1 } else { merkle_depth } ; // traverse references let mut child_mask = LevelMask :: with_mask ( 0 ) ; for update_child in update_cell . clone_references ( ) . iter ( ) { let new_child = match update_child . cell_type ( ) { CellType :: Ordinary | CellType :: MerkleProof | CellType :: MerkleUpdate => { let new_child_hash = update_child . hash ( child_merkle_depth as usize ) ; if let Some ( c ) = new_cells . get ( & new_child_hash ) { c . clone ( ) } else { let c = self . traverse_on_apply ( update_child , old_cells , new_cells , child_merkle_depth ) ? ; new_cells . insert ( new_child_hash , c . clone ( ) ) ; c } } , CellType :: PrunedBranch => { // if this pruned branch is related to current update let mask = update_child . level_mask ( ) . mask ( ) ; if mask & ( 1 << child_merkle_depth ) != 0 { // connect branch from old bag instead pruned let new_child_hash = Cell :: hash ( update_child , update_child . level ( ) as usize - 1 ) ; old_cells . get ( & new_child_hash ) . unwrap ( ) . clone ( ) } else { // else - just copy this cell (like an ordinary) update_child . clone ( ) } } , CellType :: LibraryReference => { unimplemented ! ( ) // TODO } , _ => panic ! ( " " ) } ; child_mask |= new_child . level_mask ( ) ; new_cell . append_reference_cell ( new_child ) ; } new_cell . set_level_mask ( if update_cell . is_merkle ( ) { LevelMask :: for_merkle_cell ( child_mask ) } else { child_mask } ) ; // Copy data from update to constructed cell new_cell . append_bytestring ( & SliceData :: from ( update_cell ) ) . unwrap ( ) ; new_cell . into_cell ( ) }
Recursive traverse merkle update tree while merkle update applying
`cell` ordinary cell from merkle update's new tree;
`old_cells` cells from old bag of cells;
Recursive traverse merkle update tree while merkle update applying ` cell ` ordinary cell from merkle update ' s new tree ; ` old_cells ` cells from old bag of cells ;
&self
update_cell
&Cell
old_cells
&HashMap<UInt256, Cell>
new_cells
&mut HashMap<UInt256, Cell>
merkle_depth
u8
&self
update_cell
&Cell
old_cells
&HashMap<UInt256, Cell>
new_cells
&mut HashMap<UInt256, Cell>
merkle_depth
u8