@@ -25,6 +25,9 @@ async fn main() -> Result<()> {
25
25
. spawn ( )
26
26
. await ?;
27
27
28
+ // We use a blobs client to interact with the blobs protocol we're running locally:
29
+ let blobs_client = blobs. client ( ) ;
30
+
28
31
// Grab all passed in arguments, the first one is the binary itself, so we skip it.
29
32
let args: Vec < String > = std:: env:: args ( ) . skip ( 1 ) . collect ( ) ;
30
33
// Convert to &str, so we can pattern-match easily:
@@ -35,12 +38,11 @@ async fn main() -> Result<()> {
35
38
let filename: PathBuf = filename. parse ( ) ?;
36
39
let abs_path = std:: path:: absolute ( & filename) ?;
37
40
38
- println ! ( "Analyzing file." ) ;
41
+ println ! ( "Hashing file." ) ;
39
42
40
43
// keep the file in place and link it, instead of copying it into the in-memory blobs database
41
44
let in_place = true ;
42
- let blob = blobs
43
- . client ( )
45
+ let blob = blobs_client
44
46
. add_from_path ( abs_path, in_place, SetTagOption :: Auto , WrapOption :: NoWrap )
45
47
. await ?
46
48
. finish ( )
@@ -49,7 +51,7 @@ async fn main() -> Result<()> {
49
51
let node_id = router. endpoint ( ) . node_id ( ) ;
50
52
let ticket = BlobTicket :: new ( node_id. into ( ) , blob. hash , blob. format ) ?;
51
53
52
- println ! ( "File analyzed . Fetch this file by running:" ) ;
54
+ println ! ( "File hashed . Fetch this file by running:" ) ;
53
55
println ! (
54
56
"cargo run --example transfer -- receive {ticket} {}" ,
55
57
filename. display( )
@@ -64,8 +66,7 @@ async fn main() -> Result<()> {
64
66
65
67
println ! ( "Starting download." ) ;
66
68
67
- blobs
68
- . client ( )
69
+ blobs_client
69
70
. download ( ticket. hash ( ) , ticket. node_addr ( ) . clone ( ) )
70
71
. await ?
71
72
. finish ( )
@@ -74,8 +75,7 @@ async fn main() -> Result<()> {
74
75
println ! ( "Finished download." ) ;
75
76
println ! ( "Copying to destination." ) ;
76
77
77
- blobs
78
- . client ( )
78
+ blobs_client
79
79
. export (
80
80
ticket. hash ( ) ,
81
81
abs_path,
0 commit comments