diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-02-19 20:06:10 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-02-19 20:06:10 -0800 |
commit | 4eb739dcab2a1a79e1e0e60feddb0d9cc0d74108 (patch) | |
tree | da5786d14a71ebb1f961efd37586fcd15d430371 /src/bin | |
parent | 915acb1be8693f992afd7b5c82c2761c85b6b64d (diff) | |
download | geniza-4eb739dcab2a1a79e1e0e60feddb0d9cc0d74108.tar.gz geniza-4eb739dcab2a1a79e1e0e60feddb0d9cc0d74108.zip |
more WIP on synchronizer
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/geniza.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bin/geniza.rs b/src/bin/geniza.rs index f5c73b0..72a7f8f 100644 --- a/src/bin/geniza.rs +++ b/src/bin/geniza.rs @@ -6,12 +6,14 @@ extern crate env_logger; #[macro_use] extern crate error_chain; extern crate geniza; +extern crate sodiumoxide; // TODO: more careful import use geniza::*; use std::path::{Path, PathBuf}; use clap::{App, SubCommand}; use std::env::current_dir; +use sodiumoxide::crypto::stream::Key; // Helper to find a dat directory somewhere in the parent to the current working directory (or None @@ -89,12 +91,17 @@ fn run() -> Result<()> { match matches.subcommand() { ("clone", Some(subm)) => { - let dat_key = subm.value_of("dat_key").unwrap(); - let _key_bytes = parse_dat_address(&dat_key)?; - unimplemented!(); - //let dir = Path::new(subm.value_of("dat-dir").unwrap()); - //let mut metadata = SleepDirRegister::create(&dir, "metadata")?; - //node_simple_clone(host_port, &key_bytes, &mut metadata, false)?; + let dat_key = subm.value_of("address").unwrap(); + let key_bytes = parse_dat_address(&dat_key)?; + let key = Key::from_slice(&key_bytes).unwrap(); + let dir = Path::new(subm.value_of("dir").unwrap()); + + let mut sync = Synchronizer::new_downloader(key, + SyncMode::RxMax, + dir)?; + let peer_count = sync.discover()?; + println!("Found {} potential peers", peer_count); + sync.run()?; } ("init", Some(subm)) => { let _dir = Path::new(subm.value_of("dir").unwrap()); |