nothing
This commit is contained in:
parent
2fc225cfa2
commit
e843209aa9
3 changed files with 22 additions and 18 deletions
|
|
@ -18,8 +18,9 @@ use crate::{
|
||||||
MessageOwned, Piece, Request, PIECE_MESSAGE_DEFAULT_LEN,
|
MessageOwned, Piece, Request, PIECE_MESSAGE_DEFAULT_LEN,
|
||||||
},
|
},
|
||||||
peer_id::try_decode_peer_id,
|
peer_id::try_decode_peer_id,
|
||||||
|
peer_state::InflightRequest,
|
||||||
spawn_utils::{spawn, spawn_block_in_place},
|
spawn_utils::{spawn, spawn_block_in_place},
|
||||||
torrent_state::{InflightRequest, TorrentState},
|
torrent_state::TorrentState,
|
||||||
type_aliases::PeerHandle,
|
type_aliases::PeerHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,25 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc};
|
||||||
|
|
||||||
use tokio::sync::{Notify, Semaphore};
|
use tokio::sync::{Notify, Semaphore};
|
||||||
|
|
||||||
use crate::{torrent_state::InflightRequest, type_aliases::BF};
|
use crate::{
|
||||||
|
lengths::{ChunkInfo, ValidPieceIndex},
|
||||||
|
type_aliases::BF,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||||
|
pub struct InflightRequest {
|
||||||
|
pub piece: ValidPieceIndex,
|
||||||
|
pub chunk: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&ChunkInfo> for InflightRequest {
|
||||||
|
fn from(c: &ChunkInfo) -> Self {
|
||||||
|
Self {
|
||||||
|
piece: c.piece_index,
|
||||||
|
chunk: c.chunk_index,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum PeerState {
|
pub enum PeerState {
|
||||||
Connecting(SocketAddr),
|
Connecting(SocketAddr),
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use tokio::sync::mpsc::{channel, Sender};
|
||||||
use crate::{
|
use crate::{
|
||||||
chunk_tracker::ChunkTracker,
|
chunk_tracker::ChunkTracker,
|
||||||
file_ops::FileOps,
|
file_ops::FileOps,
|
||||||
lengths::{ChunkInfo, Lengths, ValidPieceIndex},
|
lengths::{Lengths, ValidPieceIndex},
|
||||||
peer_binary_protocol::{Handshake, Message},
|
peer_binary_protocol::{Handshake, Message},
|
||||||
peer_connection::{PeerConnection, WriterRequest},
|
peer_connection::{PeerConnection, WriterRequest},
|
||||||
peer_state::{LivePeerState, PeerState},
|
peer_state::{LivePeerState, PeerState},
|
||||||
|
|
@ -25,21 +25,6 @@ use crate::{
|
||||||
type_aliases::{PeerHandle, BF},
|
type_aliases::{PeerHandle, BF},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
|
||||||
pub struct InflightRequest {
|
|
||||||
pub piece: ValidPieceIndex,
|
|
||||||
pub chunk: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&ChunkInfo> for InflightRequest {
|
|
||||||
fn from(c: &ChunkInfo) -> Self {
|
|
||||||
Self {
|
|
||||||
piece: c.piece_index,
|
|
||||||
chunk: c.chunk_index,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PeerStates {
|
pub struct PeerStates {
|
||||||
states: HashMap<PeerHandle, PeerState>,
|
states: HashMap<PeerHandle, PeerState>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue