Skip to content

Commit e503f01

Browse files
committed
feat(cat-gateway): impl Query for TxiInsertQuery
1 parent 2061696 commit e503f01

File tree

1 file changed

+21
-2
lines changed
  • catalyst-gateway/bin/src/db/index/block

1 file changed

+21
-2
lines changed

catalyst-gateway/bin/src/db/index/block/txi.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Insert TXI Index Data Queries.
22
3-
use std::sync::Arc;
3+
use std::{fmt, sync::Arc};
44

55
use cardano_blockchain_types::{Slot, TransactionId, TxnOutputOffset};
66
use catalyst_types::hashes::Blake2b256Hash;
@@ -10,7 +10,9 @@ use tracing::error;
1010
use crate::{
1111
db::{
1212
index::{
13-
queries::{FallibleQueryTasks, PreparedQueries, PreparedQuery, SizedBatch},
13+
queries::{
14+
FallibleQueryTasks, PreparedQueries, PreparedQuery, Query, QueryKind, SizedBatch,
15+
},
1416
session::CassandraSession,
1517
},
1618
types::{DbSlot, DbTransactionId, DbTxnOutputOffset},
@@ -46,9 +48,26 @@ pub(crate) struct TxiInsertQuery {
4648
txi_data: Vec<TxiInsertParams>,
4749
}
4850

51+
impl Query for TxiInsertQuery {
52+
/// Prepare Batch of Insert TXI Index Data Queries
53+
async fn prepare_query(
54+
session: &Arc<Session>, cfg: &cassandra_db::EnvVars,
55+
) -> anyhow::Result<QueryKind> {
56+
TxiInsertQuery::prepare_batch(session, cfg)
57+
.await
58+
.map(QueryKind::Batch)
59+
}
60+
}
61+
4962
/// TXI by Txn hash Index
5063
const INSERT_TXI_QUERY: &str = include_str!("./cql/insert_txi.cql");
5164

65+
impl fmt::Display for TxiInsertQuery {
66+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67+
write!(f, "{INSERT_TXI_QUERY}")
68+
}
69+
}
70+
5271
impl TxiInsertQuery {
5372
/// Create a new record for this transaction.
5473
pub(crate) fn new() -> Self {

0 commit comments

Comments
 (0)