miden-validator 0.17.4

Miden validator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Persists a block that this validator has signed.

use miden_node_db::sqlite::WriteTx;
use miden_node_db::{DatabaseError, SqlTypeConvert};
use miden_protocol::block::SignedBlock;

const SQL: &str = include_str!("insert_block.sql");

/// Inserts a block at its height, which must not already hold one; when replacing a block,
/// [`delete_block`](super::delete_block) the old block first.
pub fn insert_block(tx: &WriteTx<'_>, block: &SignedBlock) -> Result<(), DatabaseError> {
    let header = block.header();
    tx.execute(SQL, &[&header.block_num().to_raw_sql(), header, block])?;
    Ok(())
}