1use crate::schema::{blocks, local_keys, local_values, prefix_scans, storage};
2use diesel::{Insertable, Queryable, Selectable};
3
4#[derive(Insertable, Clone)]
5#[diesel(table_name = storage)]
6pub(crate) struct NewStorageRow<'a> {
7 pub block_hash: &'a [u8],
8 pub key: &'a [u8],
9 pub value: Option<&'a [u8]>,
10 pub is_empty: bool,
11}
12
13#[derive(Insertable, Clone)]
15#[diesel(table_name = local_keys)]
16pub(crate) struct NewLocalKeyRow<'a> {
17 pub key: &'a [u8],
18}
19
20#[derive(Queryable, Selectable, Clone, Debug)]
22#[diesel(table_name = local_keys)]
23pub struct LocalKeyRow {
24 pub id: i32,
25 pub key: Vec<u8>,
26}
27
28#[derive(Insertable, Clone)]
30#[diesel(table_name = local_values)]
31pub(crate) struct NewLocalValueRow {
32 pub key_id: i32,
33 pub value: Option<Vec<u8>>,
34 pub valid_from: i64,
35 pub valid_until: Option<i64>,
36}
37
38#[derive(Insertable, Clone)]
40#[diesel(table_name = blocks)]
41pub(crate) struct NewBlockRow<'a> {
42 pub hash: &'a [u8],
43 pub number: i64,
44 pub parent_hash: &'a [u8],
45 pub header: &'a [u8],
46}
47
48#[derive(Queryable, Selectable, Clone, Debug)]
50#[diesel(table_name = blocks)]
51pub struct BlockRow {
52 pub hash: Vec<u8>,
54 pub number: i64,
56 pub parent_hash: Vec<u8>,
58 pub header: Vec<u8>,
60}
61
62#[derive(Insertable, Clone)]
64#[diesel(table_name = prefix_scans)]
65pub(crate) struct NewPrefixScanRow<'a> {
66 pub(crate) block_hash: &'a [u8],
67 pub(crate) prefix: &'a [u8],
68 pub(crate) last_scanned_key: Option<&'a [u8]>,
69 pub(crate) is_complete: bool,
70}