11//! Insert TXI Index Data Queries.
22
3- use std:: sync:: Arc ;
3+ use std:: { fmt , sync:: Arc } ;
44
55use cardano_blockchain_types:: { Slot , TransactionId , TxnOutputOffset } ;
66use catalyst_types:: hashes:: Blake2b256Hash ;
@@ -10,7 +10,9 @@ use tracing::error;
1010use 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
5063const 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+
5271impl TxiInsertQuery {
5372 /// Create a new record for this transaction.
5473 pub ( crate ) fn new ( ) -> Self {
0 commit comments