Uploading seems to work fine now

This commit is contained in:
Igor Katson 2023-12-05 20:31:06 +00:00
parent efaa36a161
commit 4784f3f14b
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 17 additions and 45 deletions

View file

@ -2,8 +2,6 @@ pub mod stats;
use std::collections::HashSet;
use anyhow::Context;
use librqbit_core::id20::Id20;
use librqbit_core::lengths::{ChunkInfo, ValidPieceIndex};
@ -29,23 +27,9 @@ impl From<&ChunkInfo> for InflightRequest {
}
}
// TODO: Arc can be removed probably, as UnboundedSender should be clone + it can be downgraded to weak.
pub(crate) type PeerRx = UnboundedReceiver<WriterRequest>;
pub(crate) type PeerTx = UnboundedSender<WriterRequest>;
pub trait SendMany {
fn send_many(&self, requests: impl IntoIterator<Item = WriterRequest>) -> anyhow::Result<()>;
}
impl SendMany for PeerTx {
fn send_many(&self, requests: impl IntoIterator<Item = WriterRequest>) -> anyhow::Result<()> {
requests
.into_iter()
.try_for_each(|r| self.send(r))
.context("peer dropped")
}
}
#[derive(Debug, Default)]
pub(crate) struct Peer {
pub state: PeerStateNoMut,