p2p/disconnection_effectful/
p2p_disconnection_effectful_actions.rs1use openmina_core::ActionEvent;
2use serde::{Deserialize, Serialize};
3
4use crate::{P2pPeerStatus, P2pState, PeerId};
5
6#[derive(Serialize, Deserialize, Debug, Clone, ActionEvent)]
7#[action_event(fields(display(peer_id)), level = debug)]
8pub enum P2pDisconnectionEffectfulAction {
9 Init { peer_id: PeerId },
11}
12
13impl redux::EnablingCondition<P2pState> for P2pDisconnectionEffectfulAction {
14 fn is_enabled(&self, state: &P2pState, _time: redux::Timestamp) -> bool {
15 match self {
16 P2pDisconnectionEffectfulAction::Init { peer_id } => state
17 .peers
18 .get(peer_id)
19 .is_some_and(|peer| !matches!(peer.status, P2pPeerStatus::Disconnected { .. })),
20 }
21 }
22}