hotshot_query_service/node/
query_data.rs1use derivative::Derivative;
14use serde::{Deserialize, Serialize};
15
16pub use crate::availability::{BlockHash, BlockId};
17use crate::types::HeightIndexed;
18
19#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
20pub struct SyncStatus {
21 pub missing_blocks: usize,
22 pub missing_leaves: usize,
23 pub missing_vid_common: usize,
24 pub missing_vid_shares: usize,
25 pub pruned_height: Option<usize>,
26}
27
28impl SyncStatus {
29 pub fn fully_synced() -> Self {
30 Self {
31 missing_blocks: 0,
32 missing_leaves: 0,
33 missing_vid_common: 0,
34 missing_vid_shares: 0,
35 pruned_height: None,
36 }
37 }
38
39 pub fn is_fully_synced(&self) -> bool {
40 *self == Self::fully_synced()
41 }
42}
43
44#[derive(Clone, Debug, Derivative, PartialEq, Eq, Serialize, Deserialize)]
46#[derivative(Default(bound = ""))]
47pub struct TimeWindowQueryData<T> {
48 pub window: Vec<T>,
49 pub prev: Option<T>,
50 pub next: Option<T>,
51}
52
53impl<T: HeightIndexed> TimeWindowQueryData<T> {
54 pub fn from(&self) -> Option<u64> {
58 self.window
59 .first()
60 .or(self.next.as_ref())
61 .map(|t| t.height())
62 }
63}
64
65#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
66pub struct Limits {
67 pub window_limit: usize,
68}