cat_gateway/db/index/block/txo/
insert_unstaked_txo.rsuse std::sync::Arc;
use scylla::{SerializeRow, Session};
use tracing::error;
use crate::{
db::index::queries::{PreparedQueries, SizedBatch},
settings::cassandra_db,
};
const INSERT_UNSTAKED_TXO_QUERY: &str = include_str!("./cql/insert_unstaked_txo.cql");
#[derive(SerializeRow, Debug)]
pub(super) struct Params {
txn_hash: Vec<u8>,
txo: i16,
slot_no: num_bigint::BigInt,
txn: i16,
address: String,
value: num_bigint::BigInt,
}
impl Params {
pub(super) fn new(
txn_hash: &[u8], txo: i16, slot_no: u64, txn: i16, address: &str, value: u64,
) -> Self {
Self {
txn_hash: txn_hash.to_vec(),
txo,
slot_no: slot_no.into(),
txn,
address: address.to_string(),
value: value.into(),
}
}
pub(super) async fn prepare_batch(
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
) -> anyhow::Result<SizedBatch> {
let txo_insert_queries = PreparedQueries::prepare_batch(
session.clone(),
INSERT_UNSTAKED_TXO_QUERY,
cfg,
scylla::statement::Consistency::Any,
true,
false,
)
.await;
if let Err(ref error) = txo_insert_queries {
error!(error=%error,"Failed to prepare Insert TXO Asset Query.");
};
txo_insert_queries
}
}