cat_gateway/service/common/objects/cardano/
sync_state.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
//! Defines API schemas of Cardano sync state types.

use poem_openapi::{types::Example, Object};

use crate::service::{
    api::cardano::types::{DateTime, SlotNumber},
    common::objects::cardano::hash::Hash,
};

/// Cardano follower's sync state info.
#[derive(Object)]
#[oai(example = true)]
pub(crate) struct SyncState {
    /// Slot number.
    // TODO(bkioshn): https://github.com/input-output-hk/catalyst-voices/issues/239
    #[oai(validator(minimum(value = "0"), maximum(value = "4294967295")))]
    pub(crate) slot_number: SlotNumber,

    /// Block hash.
    pub(crate) block_hash: Hash,

    /// last updated time.
    pub(crate) last_updated: DateTime,
}

impl Example for SyncState {
    #[allow(clippy::expect_used)]
    fn example() -> Self {
        Self {
            slot_number: 5,
            block_hash: hex::decode(
                "0000000000000000000000000000000000000000000000000000000000000000",
            )
            .expect("Invalid hex")
            .into(),
            last_updated: chrono::DateTime::default(),
        }
    }
}