-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Expand file tree
/
Copy pathmodels.rs
More file actions
79 lines (70 loc) · 2.48 KB
/
models.rs
File metadata and controls
79 lines (70 loc) · 2.48 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use diesel::data_types::PgTimestamp;
use diesel::{Identifiable, Insertable, Queryable, Selectable};
use sui_indexer_builder::{Task, LIVE_TASK_TARGET_CHECKPOINT};
use crate::schema::{
progress_store, sui_error_transactions, sui_progress_store, token_transfer, token_transfer_data,
};
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug)]
#[diesel(table_name = progress_store, primary_key(task_name))]
pub struct ProgressStore {
pub task_name: String,
pub checkpoint: i64,
pub target_checkpoint: i64,
pub timestamp: Option<PgTimestamp>,
}
impl From<ProgressStore> for Task {
fn from(value: ProgressStore) -> Self {
Self {
task_name: value.task_name,
start_checkpoint: value.checkpoint as u64,
target_checkpoint: value.target_checkpoint as u64,
// Ok to unwrap, timestamp is defaulted to now() in database
timestamp: value.timestamp.expect("Timestamp not set").0 as u64,
is_live_task: value.target_checkpoint == LIVE_TASK_TARGET_CHECKPOINT,
}
}
}
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug)]
#[diesel(table_name = sui_progress_store, primary_key(txn_digest))]
pub struct SuiProgressStore {
pub id: i32, // Dummy value
pub txn_digest: Vec<u8>,
}
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug)]
#[diesel(table_name = token_transfer, primary_key(chain_id, nonce))]
pub struct TokenTransfer {
pub chain_id: i32,
pub nonce: i64,
pub status: String,
pub block_height: i64,
pub timestamp_ms: i64,
pub txn_hash: Vec<u8>,
pub txn_sender: Vec<u8>,
pub gas_usage: i64,
pub data_source: String,
}
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug)]
#[diesel(table_name = token_transfer_data, primary_key(chain_id, nonce))]
pub struct TokenTransferData {
pub chain_id: i32,
pub nonce: i64,
pub block_height: i64,
pub timestamp_ms: i64,
pub txn_hash: Vec<u8>,
pub sender_address: Vec<u8>,
pub destination_chain: i32,
pub recipient_address: Vec<u8>,
pub token_id: i32,
pub amount: i64,
}
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug)]
#[diesel(table_name = sui_error_transactions, primary_key(txn_digest))]
pub struct SuiErrorTransactions {
pub txn_digest: Vec<u8>,
pub sender_address: Vec<u8>,
pub timestamp_ms: i64,
pub failure_status: String,
pub cmd_idx: Option<i64>,
}