p2p/connection/outgoing_effectful/
p2p_connection_outgoing_effectful_actions.rs1use openmina_core::ActionEvent;
2use serde::{Deserialize, Serialize};
3
4use openmina_core::requests::RpcId;
5
6use crate::{
7 connection::{outgoing::P2pConnectionOutgoingInitOpts, P2pConnectionEffectfulAction},
8 identity::PublicKey,
9 webrtc::{self, ConnectionAuth, SignalingMethod},
10 P2pState, PeerId,
11};
12
13#[derive(Serialize, Deserialize, Debug, Clone, ActionEvent)]
14#[action_event(fields(display(opts), display(peer_id), display(error)))]
15pub enum P2pConnectionOutgoingEffectfulAction {
16 #[action_event(level = trace)]
18 RandomInit {
19 peers: Vec<P2pConnectionOutgoingInitOpts>,
20 },
21 #[action_event(level = info)]
23 Init {
24 opts: P2pConnectionOutgoingInitOpts,
25 rpc_id: Option<RpcId>,
26 },
27 OfferSend {
28 peer_id: PeerId,
29 offer: Box<webrtc::Offer>,
30 signaling_method: SignalingMethod,
31 },
32 AnswerSet {
33 peer_id: PeerId,
34 answer: Box<webrtc::Answer>,
35 },
36 ConnectionAuthorizationEncryptAndSend {
37 peer_id: PeerId,
38 other_pub_key: PublicKey,
39 auth: ConnectionAuth,
40 },
41 ConnectionAuthorizationDecryptAndCheck {
42 peer_id: PeerId,
43 other_pub_key: PublicKey,
44 expected_auth: ConnectionAuth,
45 auth: webrtc::ConnectionAuthEncrypted,
46 },
47}
48
49impl redux::EnablingCondition<P2pState> for P2pConnectionOutgoingEffectfulAction {
50 fn is_enabled(&self, _: &P2pState, _: redux::Timestamp) -> bool {
51 true
52 }
53}
54
55impl From<P2pConnectionOutgoingEffectfulAction> for crate::P2pEffectfulAction {
56 fn from(a: P2pConnectionOutgoingEffectfulAction) -> crate::P2pEffectfulAction {
57 crate::P2pEffectfulAction::Connection(P2pConnectionEffectfulAction::Outgoing(a))
58 }
59}