pub fn horizon_sync_commit(&self) -> Result<(), ChainStorageError> {
        let mut db = self.db_write_access()?;
        let tip_header = db
            .fetch_last_header()?
            .ok_or_else(|| ChainStorageError::InvalidQuery("Cannot retrieve header. Blockchain DB is empty".into()))?;

        let mut txn = DbTransaction::new();

        // Update metadata
        txn.set_metadata(
            MetadataKey::ChainHeight,
            MetadataValue::ChainHeight(Some(tip_header.height)),
        );

        let best_block = tip_header.hash();
        txn.set_metadata(MetadataKey::BestBlock, MetadataValue::BestBlock(Some(best_block)));

        let accumulated_difficulty =
            ProofOfWork::new_from_difficulty(&tip_header.pow, ProofOfWork::achieved_difficulty(&tip_header)?)
                .total_accumulated_difficulty();
        txn.set_metadata(
            MetadataKey::AccumulatedWork,
            MetadataValue::AccumulatedWork(Some(accumulated_difficulty)),
        );

        txn.set_metadata(
            MetadataKey::EffectivePrunedHeight,
            MetadataValue::EffectivePrunedHeight(tip_header.height),
        );

        // Merge all MMR checkpoints created during horizon sync into a single checkpoint
        txn.merge_checkpoints(1);

        // Remove pending horizon sync state
        txn.delete_metadata(MetadataKey::HorizonSyncState);

        commit(&mut *db, txn)
    }
/// Commit the current synced horizon state.
Commit the current synced horizon state.
Commit the current synced horizon state .
pub fn horizon_sync_commit(&self) -> Result<(), ChainStorageError> {
        let mut db = self.db_write_access()?;
        let tip_header = db
            .fetch_last_header()?
            .ok_or_else(|| ChainStorageError::InvalidQuery("Cannot retrieve header. Blockchain DB is empty".into()))?;
        let mut txn = DbTransaction::new();
        // Update metadata
        txn.set_metadata(
            MetadataKey::ChainHeight,
            MetadataValue::ChainHeight(Some(tip_header.height)),
        );
        let best_block = tip_header.hash();
        txn.set_metadata(MetadataKey::BestBlock, MetadataValue::BestBlock(Some(best_block)));
        let accumulated_difficulty =
            ProofOfWork::new_from_difficulty(&tip_header.pow, ProofOfWork::achieved_difficulty(&tip_header)?)
                .total_accumulated_difficulty();
        txn.set_metadata(
            MetadataKey::AccumulatedWork,
            MetadataValue::AccumulatedWork(Some(accumulated_difficulty)),
        );
        txn.set_metadata(
            MetadataKey::EffectivePrunedHeight,
            MetadataValue::EffectivePrunedHeight(tip_header.height),
        );
        // Merge all MMR checkpoints created during horizon sync into a single checkpoint
        txn.merge_checkpoints(1);
        // Remove pending horizon sync state
        txn.delete_metadata(MetadataKey::HorizonSyncState);
        commit(&mut *db, txn)
    }
pub fn horizon_sync_commit ( & self ) -> Result < ( ) , ChainStorageError > { let mut db = self . db_write_access ( ) ? ; let tip_header = db . fetch_last_header ( ) ? . ok_or_else ( | | ChainStorageError :: InvalidQuery ( " " . into ( ) ) ) ? ; let mut txn = DbTransaction :: new ( ) ; // Update metadata txn . set_metadata ( MetadataKey :: ChainHeight , MetadataValue :: ChainHeight ( Some ( tip_header . height ) ) , ) ; let best_block = tip_header . hash ( ) ; txn . set_metadata ( MetadataKey :: BestBlock , MetadataValue :: BestBlock ( Some ( best_block ) ) ) ; let accumulated_difficulty = ProofOfWork :: new_from_difficulty ( & tip_header . pow , ProofOfWork :: achieved_difficulty ( & tip_header ) ? ) . total_accumulated_difficulty ( ) ; txn . set_metadata ( MetadataKey :: AccumulatedWork , MetadataValue :: AccumulatedWork ( Some ( accumulated_difficulty ) ) , ) ; txn . set_metadata ( MetadataKey :: EffectivePrunedHeight , MetadataValue :: EffectivePrunedHeight ( tip_header . height ) , ) ; // Merge all MMR checkpoints created during horizon sync into a single checkpoint txn . merge_checkpoints ( 1 ) ; // Remove pending horizon sync state txn . delete_metadata ( MetadataKey :: HorizonSyncState ) ; commit ( & mut * db , txn ) }
Commit the current synced horizon state.
Commit the current synced horizon state .
&self
&self