This commit is contained in:
Igor Katson 2021-06-30 00:00:44 +01:00
parent 2fc225cfa2
commit e843209aa9
3 changed files with 22 additions and 18 deletions

View file

@ -2,7 +2,25 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc};
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 {
Connecting(SocketAddr),