/
model.rs
46 lines (40 loc) · 1.22 KB
/
model.rs
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
use bigdecimal::BigDecimal;
use diesel::sql_types::{Numeric, Timestamp};
use diesel::{Queryable, QueryableByName};
use serde::{Deserialize, Serialize};
use std::time::SystemTime;
#[derive(Queryable, PartialEq, Eq, Debug, Serialize, Clone)]
pub struct Meta {
pub id: i64,
pub start_time: SystemTime,
pub version: String,
pub network_name: String,
}
#[derive(QueryableByName, Debug, Serialize, Deserialize, Clone)]
pub struct BehindDuration {
#[diesel(sql_type = Timestamp)]
behind_by: SystemTime,
}
#[derive(QueryableByName, Debug, Serialize, Deserialize, Clone)]
pub struct Progress {
#[diesel(sql_type = Numeric)]
sync_percentage: BigDecimal,
}
#[derive(Debug, Serialize)]
pub struct TransactionConfirmation {
epoch_no: Option<i32>,
slot_no: Option<i64>,
absolute_slot: Option<i32>,
block_no: Option<i32>,
}
impl From<TransactionConfirmationRow> for TransactionConfirmation {
fn from(row: TransactionConfirmationRow) -> Self {
TransactionConfirmation {
epoch_no: row.0,
slot_no: row.1,
absolute_slot: row.2,
block_no: row.3,
}
}
}
pub type TransactionConfirmationRow = (Option<i32>, Option<i64>, Option<i32>, Option<i32>);