1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use std::fmt::Debug;

use ::clickhouse::{DbRow, InsertRow};
pub mod address_metadata;
pub mod address_to_protocol_info;

#[rustfmt::skip]
pub mod block_analysis;
pub mod block_times;
pub mod builder;
pub mod cex;

pub mod clickhouse;
pub mod clickhouse_serde;
pub mod codecs;
pub mod dex;
pub mod initialized_state;
pub mod metadata;
pub mod mev_block;
pub mod normalized_actions;
pub mod pool_creation_block;
pub mod redefined_types;
pub mod searcher;
pub mod token_info;
pub mod traces;
pub mod traits;

/// This table is used to add run id inserts for each clickhouse table in order
/// for us to not have to clear runs multiple times
#[derive(Debug, Clone, serde::Serialize)]
pub struct DbDataWithRunId<Table: Debug + Clone + serde::Serialize + DbRow + Sync + Send> {
    pub table:  Table,
    pub run_id: u64,
}

impl<Table: Debug + Clone + serde::Serialize + DbRow + Sync + Send> DbDataWithRunId<Table> {
    pub fn new_with_run_id(table: Table, run_id: u64) -> Self {
        Self { table, run_id }
    }
}

impl<Table: Debug + Clone + serde::Serialize + DbRow + Sync + Send> InsertRow
    for DbDataWithRunId<Table>
{
    fn get_column_names(&self) -> &'static [&'static str] {
        let inner = Table::COLUMN_NAMES;
        let mut res = Vec::new();
        for i in inner {
            res.push(*i);
        }
        res.push("run_id");
        let sliced = res.into_boxed_slice();

        Box::leak(sliced)
    }
}

#[derive(Debug, Clone, serde::Serialize, ::clickhouse::Row)]
pub struct RunId {
    pub run_id: u64,
}

impl From<u64> for RunId {
    fn from(value: u64) -> Self {
        Self { run_id: value }
    }
}