/// Commit the given block id with the proof, returns () on success or error
Commit the given block id with the proof, returns () on success or error
Commit the given block id with the proof returns () on success or error
pub async fn commit(&self, finality_proof: LedgerInfoWithSignatures) -> anyhow::Result<()> {
        let block_id_to_commit = finality_proof.ledger_info().consensus_block_id();
        let block_to_commit = self
            .get_block(block_id_to_commit)
            .ok_or_else(|| format_err!("Committed block id not found"))?;
        // First make sure that this commit is new.
        ensure!(
            block_to_commit.round() > self.root().round(),
            "Committed block round lower than root"
        );
        let blocks_to_commit = self
            .path_from_root(block_id_to_commit)
            .unwrap_or_else(Vec::new);
        for block in &blocks_to_commit {
            end_trace!("commit", {"block", block.id()});
        }
        self.state_computer
            .commit(
                blocks_to_commit.iter().map(|b| b.id()).collect(),
                finality_proof,
            )
            .await
            .expect("Failed to persist commit");
        update_counters_for_committed_blocks(&blocks_to_commit);
        debug!("{}Committed{} {}", Fg(Blue), Fg(Reset), *block_to_commit);
        event!("committed",
            "block_id": block_to_commit.id().short_str(),
            "round": block_to_commit.round(),
            "parent_id": block_to_commit.parent_id().short_str(),
        );
        self.prune_tree(block_to_commit.id());
        Ok(())
    }
pub async fn commit ( & self , finality_proof : LedgerInfoWithSignatures ) -> anyhow :: Result < ( ) > { let block_id_to_commit = finality_proof . ledger_info ( ) . consensus_block_id ( ) ; let block_to_commit = self . get_block ( block_id_to_commit ) . ok_or_else ( | | format_err ! ( " " ) ) ? ; // First make sure that this commit is new. ensure ! ( block_to_commit round ( ) self root ( ) round ( ) " " ) ; let blocks_to_commit = self . path_from_root ( block_id_to_commit ) . unwrap_or_else ( Vec :: new ) ; for block in & blocks_to_commit { end_trace ! ( " " { " " block id ( ) } ) ; } self . state_computer . commit ( blocks_to_commit . iter ( ) . map ( | b | b . id ( ) ) . collect ( ) , finality_proof , ) . await . expect ( " " ) ; update_counters_for_committed_blocks ( & blocks_to_commit ) ; debug ! ( " " Fg ( Blue ) Fg ( Reset ) block_to_commit ) ; event ! ( " " " " block_to_commit id ( ) short_str ( ) " " block_to_commit round ( ) " " block_to_commit parent_id ( ) short_str ( ) ) ; self . prune_tree ( block_to_commit . id ( ) ) ; Ok ( ( ) ) }
Commit the given block id with the proof, returns () on success or error
Commit the given block id with the proof returns () on success or error
&self
finality_proof
LedgerInfoWithSignatures