iota_indexer/store/
indexer_analytics_store.rs1use async_trait::async_trait;
6
7use crate::{
8 models::{
9 checkpoints::StoredCheckpoint,
10 move_call_metrics::StoredMoveCallMetrics,
11 network_metrics::StoredEpochPeakTps,
12 transactions::{
13 StoredTransaction, StoredTransactionCheckpoint, StoredTransactionSuccessCommandCount,
14 StoredTransactionTimestamp, TxSeq,
15 },
16 tx_count_metrics::StoredTxCountMetrics,
17 },
18 types::IndexerResult,
19};
20
21#[async_trait]
24pub trait IndexerAnalyticalStore {
25 async fn get_latest_stored_transaction(&self) -> IndexerResult<Option<StoredTransaction>>;
26 async fn get_latest_stored_checkpoint(&self) -> IndexerResult<Option<StoredCheckpoint>>;
27 async fn get_checkpoints_in_range(
28 &self,
29 start_checkpoint: i64,
30 end_checkpoint: i64,
31 ) -> IndexerResult<Vec<StoredCheckpoint>>;
32 async fn get_tx_timestamps_in_checkpoint_range(
33 &self,
34 start_checkpoint: i64,
35 end_checkpoint: i64,
36 ) -> IndexerResult<Vec<StoredTransactionTimestamp>>;
37 async fn get_tx_checkpoints_in_checkpoint_range(
38 &self,
39 start_checkpoint: i64,
40 end_checkpoint: i64,
41 ) -> IndexerResult<Vec<StoredTransactionCheckpoint>>;
42 async fn get_tx_success_cmd_counts_in_checkpoint_range(
43 &self,
44 start_checkpoint: i64,
45 end_checkpoint: i64,
46 ) -> IndexerResult<Vec<StoredTransactionSuccessCommandCount>>;
47 async fn get_tx(&self, tx_sequence_number: i64) -> IndexerResult<Option<StoredTransaction>>;
48 async fn get_cp(&self, sequence_number: i64) -> IndexerResult<Option<StoredCheckpoint>>;
49
50 async fn get_latest_tx_count_metrics(&self) -> IndexerResult<Option<StoredTxCountMetrics>>;
52 async fn get_latest_epoch_peak_tps(&self) -> IndexerResult<Option<StoredEpochPeakTps>>;
53 fn persist_tx_count_metrics(
54 &self,
55 start_checkpoint: i64,
56 end_checkpoint: i64,
57 ) -> IndexerResult<()>;
58 async fn persist_epoch_peak_tps(&self, epoch: i64) -> IndexerResult<()>;
59
60 async fn get_address_metrics_last_processed_tx_seq(&self) -> IndexerResult<Option<TxSeq>>;
62 fn persist_addresses_in_tx_range(
63 &self,
64 start_tx_seq: i64,
65 end_tx_seq: i64,
66 ) -> IndexerResult<()>;
67 fn persist_active_addresses_in_tx_range(
68 &self,
69 start_tx_seq: i64,
70 end_tx_seq: i64,
71 ) -> IndexerResult<()>;
72 async fn calculate_and_persist_address_metrics(&self, checkpoint: i64) -> IndexerResult<()>;
73
74 async fn get_latest_move_call_metrics(&self) -> IndexerResult<Option<StoredMoveCallMetrics>>;
76 async fn get_latest_move_call_tx_seq(&self) -> IndexerResult<Option<TxSeq>>;
77 fn persist_move_calls_in_tx_range(
78 &self,
79 start_tx_seq: i64,
80 end_tx_seq: i64,
81 ) -> IndexerResult<()>;
82 async fn calculate_and_persist_move_call_metrics(&self, epoch: i64) -> IndexerResult<()>;
83}