p2p/channels/best_tip/
p2p_channels_best_tip_state.rs1use openmina_core::block::ArcBlockWithHash;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub enum P2pChannelsBestTipState {
6 Disabled,
7 Enabled,
8 Init {
9 time: redux::Timestamp,
10 },
11 Pending {
12 time: redux::Timestamp,
13 },
14 Ready {
15 time: redux::Timestamp,
16 local: BestTipPropagationState,
18 remote: BestTipPropagationState,
20 last_sent: Option<ArcBlockWithHash>,
21 last_received: Option<ArcBlockWithHash>,
22 },
23}
24
25#[derive(Serialize, Deserialize, Debug, Clone)]
26pub enum BestTipPropagationState {
27 WaitingForRequest { time: redux::Timestamp },
28 Requested { time: redux::Timestamp },
29 Responded { time: redux::Timestamp },
30}
31
32impl P2pChannelsBestTipState {
33 pub fn is_ready(&self) -> bool {
34 matches!(self, Self::Ready { .. })
35 }
36}