File tree Expand file tree Collapse file tree 3 files changed +31
-24
lines changed Expand file tree Collapse file tree 3 files changed +31
-24
lines changed Original file line number Diff line number Diff 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 ) ]
223212pub 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 ) ]
378355pub struct StaticContentDiscovery {
Original file line number Diff line number Diff line change 1+ //! The actor for the downloader
12use 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+
317pub ( super ) struct DownloaderActor < S > {
418 local_pool : LocalPool ,
519 endpoint : Endpoint ,
Original file line number Diff line number Diff line change 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.
27use 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) ]
892908mod tests {
893909
You can’t perform that action at this time.
0 commit comments