Skip to content

Commit 0706098

Browse files
committed
more moving stuff around
1 parent e3ff68f commit 0706098

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

src/downloader2.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,6 @@ pub enum BitfieldPeer {
207207
Remote(NodeId),
208208
}
209209

210-
fn total_chunks(chunks: &ChunkRanges) -> Option<u64> {
211-
let mut total = 0;
212-
for range in chunks.iter() {
213-
match range {
214-
RangeSetRange::RangeFrom(_range) => return None,
215-
RangeSetRange::Range(range) => total += range.end.0 - range.start.0,
216-
}
217-
}
218-
Some(total)
219-
}
220-
221210
/// A downloader that allows range downloads and downloads from multiple peers.
222211
#[derive(Debug, Clone)]
223212
pub struct Downloader {
@@ -361,18 +350,6 @@ impl Downloader {
361350
}
362351
}
363352

364-
/// An user-facing command
365-
#[derive(Debug)]
366-
pub(super) enum UserCommand {
367-
Download {
368-
request: DownloadRequest,
369-
done: tokio::sync::oneshot::Sender<()>,
370-
},
371-
Observe {
372-
request: ObserveRequest,
373-
send: tokio::sync::mpsc::Sender<ObserveEvent>,
374-
},
375-
}
376353
/// A simple static content discovery mechanism
377354
#[derive(Debug)]
378355
pub struct StaticContentDiscovery {

src/downloader2/actor.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
//! The actor for the downloader
12
use super::*;
23

4+
/// An user-facing command
5+
#[derive(Debug)]
6+
pub(super) enum UserCommand {
7+
Download {
8+
request: DownloadRequest,
9+
done: tokio::sync::oneshot::Sender<()>,
10+
},
11+
Observe {
12+
request: ObserveRequest,
13+
send: tokio::sync::mpsc::Sender<ObserveEvent>,
14+
},
15+
}
16+
317
pub(super) struct DownloaderActor<S> {
418
local_pool: LocalPool,
519
endpoint: Endpoint,

src/downloader2/state.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
//! The state machine for the downloader
1+
//! The state machine for the downloader, as well as the commands and events.
2+
//!
3+
//! In addition to the state machine, there are also some structs encapsulating
4+
//! a part of the state. These are at this point just wrappers around a single
5+
//! map, but can be made more efficient later if needed without breaking the
6+
//! interface.
27
use super::*;
38

49
#[derive(Debug)]
@@ -888,6 +893,17 @@ impl PeerBlobState {
888893
}
889894
}
890895

896+
fn total_chunks(chunks: &ChunkRanges) -> Option<u64> {
897+
let mut total = 0;
898+
for range in chunks.iter() {
899+
match range {
900+
RangeSetRange::RangeFrom(_range) => return None,
901+
RangeSetRange::Range(range) => total += range.end.0 - range.start.0,
902+
}
903+
}
904+
Some(total)
905+
}
906+
891907
#[cfg(test)]
892908
mod tests {
893909

0 commit comments

Comments
 (0)