p2p_chat/network/layer/
state.rs1use std::collections::HashMap;
3use std::sync::Arc;
4
5use libp2p::{request_response::OutboundRequestId, swarm::Swarm, PeerId};
6use tokio::sync::{mpsc, oneshot};
7
8use crate::cli::commands::UiNotification;
9use crate::storage::SledMailboxStore;
10use crate::sync::SyncEvent;
11
12use super::super::behaviour::P2PBehaviour;
13use super::super::message::{NetworkCommand, NetworkResponse};
14
15pub struct NetworkLayer {
21 pub(crate) swarm: Swarm<P2PBehaviour>,
23 pub(crate) command_receiver: mpsc::UnboundedReceiver<NetworkCommand>,
25 pub(crate) pending_requests: HashMap<OutboundRequestId, oneshot::Sender<NetworkResponse>>,
27 pub(crate) sync_event_tx: Option<mpsc::UnboundedSender<SyncEvent>>,
29 pub(crate) ui_notify_tx: Option<mpsc::UnboundedSender<UiNotification>>,
31 pub(crate) mailbox_storage: Option<Arc<SledMailboxStore>>,
33 pub(crate) blocked_peers: HashMap<PeerId, std::time::Instant>,
35}