2/n Wrap PeerState into peer
This commit is contained in:
parent
8e50829586
commit
55e692d476
2 changed files with 50 additions and 23 deletions
|
|
@ -2,7 +2,7 @@ use std::{collections::HashSet, sync::Arc};
|
|||
|
||||
use librqbit_core::id20::Id20;
|
||||
use librqbit_core::lengths::{ChunkInfo, ValidPieceIndex};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use tokio::sync::{Notify, Semaphore};
|
||||
|
||||
use crate::peer_connection::WriterRequest;
|
||||
|
|
@ -24,8 +24,20 @@ impl From<&ChunkInfo> for InflightRequest {
|
|||
}
|
||||
|
||||
// TODO: Arc can be removed probably, as UnboundedSender should be clone + it can be downgraded to weak.
|
||||
pub type PeerRx = UnboundedReceiver<WriterRequest>;
|
||||
pub type PeerTx = Arc<UnboundedSender<WriterRequest>>;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PeerStats {
|
||||
pub unsuccessful_connection_attempts: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Peer {
|
||||
pub state: PeerState,
|
||||
pub stats: PeerStats,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub enum PeerState {
|
||||
#[default]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue