// FIXME: Make `prune` return `BlockStoreError` on error
Make `prune` return `BlockStoreError` on error
Make ` prune ` return ` BlockStoreError ` on error
pub fn prune(&mut self, hb: &HashedBlock, balances: &BalanceBook) -> Result<(), String> {
        self.write_oldest_block_snapshot(hb, balances)?;
        let mut connection = self.connection.lock().unwrap();
        let tx = connection.transaction().expect("Cannot open transaction");
        // NB: An optimization would be to update only modified accounts.
        tx.execute(
            "DELETE FROM books WHERE block_idx > 0 AND block_idx < ?",
            params![hb.index],
        )
        .map_err(|e| e.to_string())?;
        tx.execute(
            "DELETE FROM balances WHERE block_idx > 0 AND block_idx < ?",
            params![hb.index],
        )
        .map_err(|e| e.to_string())?;
        tx.execute(
            "DELETE FROM blocks WHERE idx > 0 AND idx < ?",
            params![hb.index],
        )
        .map_err(|e| e.to_string())?;
        self.base_idx = hb.index;
        tx.commit().map_err(|e| e.to_string())?;
        Ok(())
    }
pub fn prune ( & mut self , hb : & HashedBlock , balances : & BalanceBook ) -> Result < ( ) , String > { self . write_oldest_block_snapshot ( hb , balances ) ? ; let mut connection = self . connection . lock ( ) . unwrap ( ) ; let tx = connection . transaction ( ) . expect ( " " ) ; // NB: An optimization would be to update only modified accounts. tx . execute ( " " , params ! [ hb index ] , ) . map_err ( | e | e . to_string ( ) ) ? ; tx . execute ( " " , params ! [ hb index ] , ) . map_err ( | e | e . to_string ( ) ) ? ; tx . execute ( " " , params ! [ hb index ] , ) . map_err ( | e | e . to_string ( ) ) ? ; self . base_idx = hb . index ; tx . commit ( ) . map_err ( | e | e . to_string ( ) ) ? ; Ok ( ( ) ) }
FIXME: Make `prune` return `BlockStoreError` on error
FIXME : Make ` prune ` return ` BlockStoreError ` on error
&mut self
hb
&HashedBlock
balances
&BalanceBook