zksync_node_api_server 29.13.0-non-semver-compat

ZKsync API server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Utils specific to the API server.

use zksync_dal::{Connection, Core, DalError};
use zksync_web3_decl::error::Web3Error;

/// Opens a readonly transaction over the specified connection.
pub(crate) async fn open_readonly_transaction<'r>(
    conn: &'r mut Connection<'_, Core>,
) -> Result<Connection<'r, Core>, Web3Error> {
    let builder = conn.transaction_builder().map_err(DalError::generalize)?;
    Ok(builder
        .set_readonly()
        .build()
        .await
        .map_err(DalError::generalize)?)
}