diff --git a/README.md b/README.md index 83ca9b4a..adeeb022 100644 --- a/README.md +++ b/README.md @@ -63,10 +63,8 @@ use ipfs::{IpfsOptions, IpfsPath, Ipld, Types, UninitializedIpfs}; use libipld::ipld; fn main() { + env_logger::init(); let options = IpfsOptions::::default(); - env_logger::Builder::new() - .parse_filters(&options.ipfs_log) - .init(); task::block_on(async move { // Start daemon and initialize repo diff --git a/examples/examples/client1.rs b/examples/examples/client1.rs index 35dbd7df..d2b4cc2b 100644 --- a/examples/examples/client1.rs +++ b/examples/examples/client1.rs @@ -4,10 +4,8 @@ use ipfs::{IpfsOptions, Types, UninitializedIpfs}; use libipld::ipld; fn main() { + env_logger::init(); let options = IpfsOptions::::default(); - env_logger::Builder::new() - .parse_filters(&options.ipfs_log) - .init(); task::block_on(async move { let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap(); diff --git a/examples/examples/client2.rs b/examples/examples/client2.rs index ef55bae0..4b572bd9 100644 --- a/examples/examples/client2.rs +++ b/examples/examples/client2.rs @@ -4,10 +4,8 @@ use ipfs::{IpfsOptions, IpfsPath, TestTypes, UninitializedIpfs}; use std::str::FromStr; fn main() { + env_logger::init(); let options = IpfsOptions::::default(); - env_logger::Builder::new() - .parse_filters(&options.ipfs_log) - .init(); let path = IpfsPath::from_str("/ipfs/zdpuB1caPcm4QNXeegatVfLQ839Lmprd5zosXGwRUBJHwj66X").unwrap(); diff --git a/examples/examples/ipfs_bitswap_test.rs b/examples/examples/ipfs_bitswap_test.rs index b2126180..62977162 100644 --- a/examples/examples/ipfs_bitswap_test.rs +++ b/examples/examples/ipfs_bitswap_test.rs @@ -5,10 +5,8 @@ use multihash::Sha2_256; use std::convert::TryInto; fn main() { + env_logger::init(); let options = IpfsOptions::::default(); - env_logger::Builder::new() - .parse_filters(&options.ipfs_log) - .init(); task::block_on(async move { // Start daemon and initialize repo diff --git a/examples/examples/ipfs_ipns_test.rs b/examples/examples/ipfs_ipns_test.rs index 6ea78d8d..1d9897b4 100644 --- a/examples/examples/ipfs_ipns_test.rs +++ b/examples/examples/ipfs_ipns_test.rs @@ -3,10 +3,8 @@ use ipfs::{IpfsOptions, IpfsPath, PeerId, TestTypes, UninitializedIpfs}; use std::str::FromStr; fn main() { + env_logger::init(); let options = IpfsOptions::::default(); - env_logger::Builder::new() - .parse_filters(&options.ipfs_log) - .init(); task::block_on(async move { // Start daemon and initialize repo diff --git a/src/config.rs b/src/config.rs index 725bcb86..fa2d37a2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -151,6 +151,7 @@ impl ConfigFile { } pub fn store_at>(&self, path: P) -> std::io::Result<()> { + fs::create_dir_all(path.as_ref().parent().unwrap())?; let string = serde_json::to_string_pretty(self).unwrap(); fs::write(path, string) } diff --git a/src/p2p/swarm.rs b/src/p2p/swarm.rs index e8af8e42..a73b599b 100644 --- a/src/p2p/swarm.rs +++ b/src/p2p/swarm.rs @@ -22,7 +22,7 @@ pub struct Disconnector { impl Disconnector { pub fn disconnect(self, swarm: &mut Swarm) { Swarm::ban_peer_id(swarm, self.peer_id.clone()); - Swarm::unban_peer_id(swarm, self.peer_id.clone()); + Swarm::unban_peer_id(swarm, self.peer_id); } } @@ -144,6 +144,7 @@ impl NetworkBehaviour for SwarmApi { .finish_subscription(addr, Err(format!("{}", error))); } + #[allow(clippy::type_complexity)] fn poll(&mut self, _ctx: &mut Context, _: &mut impl PollParameters) -> Poll::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>{ log::trace!("poll");