diff --git a/Cargo.toml b/Cargo.toml index 6ca8c4dd..1342ae8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,35 +62,34 @@ atomic = "0.5.0" bytes = "0.5" futures = "0.3.1" lazy_static = "1.2" -libp2p-core = { version = "0.24.0", path = "core" } +libp2p-core = { version = "0.25.0", path = "core" } libp2p-core-derive = { version = "0.20.2", path = "misc/core-derive" } -libp2p-floodsub = { version = "0.24.0", path = "protocols/floodsub", optional = true } -libp2p-gossipsub = { version = "0.24.0", path = "./protocols/gossipsub", optional = true } -libp2p-identify = { version = "0.24.0", path = "protocols/identify", optional = true } -libp2p-kad = { version = "0.25.0", path = "protocols/kad", optional = true } -libp2p-mplex = { version = "0.24.0", path = "muxers/mplex", optional = true } -libp2p-noise = { version = "0.26.0", path = "protocols/noise", optional = true } -libp2p-ping = { version = "0.24.0", path = "protocols/ping", optional = true } -libp2p-plaintext = { version = "0.24.1", path = "protocols/plaintext", optional = true } +libp2p-floodsub = { version = "0.25.0", path = "protocols/floodsub", optional = true } +libp2p-gossipsub = { version = "0.25.0", path = "./protocols/gossipsub", optional = true } +libp2p-identify = { version = "0.25.0", path = "protocols/identify", optional = true } +libp2p-kad = { version = "0.26.0", path = "protocols/kad", optional = true } +libp2p-mplex = { version = "0.25.0", path = "muxers/mplex", optional = true } +libp2p-noise = { version = "0.27.0", path = "protocols/noise", optional = true } +libp2p-ping = { version = "0.25.0", path = "protocols/ping", optional = true } +libp2p-plaintext = { version = "0.25.0", path = "protocols/plaintext", optional = true } libp2p-pnet = { version = "0.19.2", path = "protocols/pnet", optional = true } -libp2p-request-response = { version = "0.5.0", path = "protocols/request-response", optional = true } -libp2p-swarm = { version = "0.24.0", path = "swarm" } -libp2p-uds = { version = "0.24.0", path = "transports/uds", optional = true } -libp2p-wasm-ext = { version = "0.24.0", path = "transports/wasm-ext", optional = true } -libp2p-yamux = { version = "0.27.0", path = "muxers/yamux", optional = true } +libp2p-request-response = { version = "0.6.0", path = "protocols/request-response", optional = true } +libp2p-swarm = { version = "0.25.0", path = "swarm" } +libp2p-uds = { version = "0.25.0", path = "transports/uds", optional = true } +libp2p-wasm-ext = { version = "0.25.0", path = "transports/wasm-ext", optional = true } +libp2p-yamux = { version = "0.28.0", path = "muxers/yamux", optional = true } multiaddr = { package = "parity-multiaddr", version = "0.9.4", path = "misc/multiaddr" } -multihash = "0.11.3" parking_lot = "0.11.0" pin-project = "1.0.0" smallvec = "1.0" wasm-timer = "0.2.4" [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] -libp2p-deflate = { version = "0.24.0", path = "protocols/deflate", optional = true } -libp2p-dns = { version = "0.24.0", path = "transports/dns", optional = true } -libp2p-mdns = { version = "0.24.0", path = "protocols/mdns", optional = true } -libp2p-tcp = { version = "0.24.0", path = "transports/tcp", optional = true } -libp2p-websocket = { version = "0.25.0", path = "transports/websocket", optional = true } +libp2p-deflate = { version = "0.25.0", path = "protocols/deflate", optional = true } +libp2p-dns = { version = "0.25.0", path = "transports/dns", optional = true } +libp2p-mdns = { version = "0.25.0", path = "protocols/mdns", optional = true } +libp2p-tcp = { version = "0.25.0", path = "transports/tcp", optional = true } +libp2p-websocket = { version = "0.26.0", path = "transports/websocket", optional = true } [dev-dependencies] async-std = "1.6.2" diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 10fe52ec..837c2221 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `multihash`. + # 0.24.0 [2020-11-09] - Remove `ConnectionInfo` trait and replace it with `PeerId` diff --git a/core/Cargo.toml b/core/Cargo.toml index 85f822da..5e8724cd 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-core" edition = "2018" description = "Core traits and structs of libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,6 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asn1_der = "0.6.1" bs58 = "0.4.0" +bytes = "0.5" ed25519-dalek = "1.0.1" either = "1.5" fnv = "1.0" @@ -21,7 +22,7 @@ lazy_static = "1.2" libsecp256k1 = { version = "0.3.1", optional = true } log = "0.4" multiaddr = { package = "parity-multiaddr", version = "0.9.4", path = "../misc/multiaddr" } -multihash = "0.11.3" +multihash = { version = "0.13", default-features = false, features = ["std", "multihash-impl", "identity", "sha2"] } multistream-select = { version = "0.8.5", path = "../misc/multistream-select" } parking_lot = "0.11.0" pin-project = "1.0.0" @@ -43,6 +44,7 @@ async-std = "1.6.2" libp2p-mplex = { path = "../muxers/mplex" } libp2p-noise = { path = "../protocols/noise" } libp2p-tcp = { path = "../transports/tcp", features = ["async-std"] } +multihash = { version = "0.13", default-features = false, features = ["arb"] } quickcheck = "0.9.0" wasm-timer = "0.2" diff --git a/core/src/lib.rs b/core/src/lib.rs index e27f13f1..e2836a1e 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -55,6 +55,7 @@ pub mod transport; pub mod upgrade; pub use multiaddr::Multiaddr; +pub use multihash; pub use muxing::StreamMuxer; pub use peer_id::PeerId; pub use identity::PublicKey; diff --git a/core/src/peer_id.rs b/core/src/peer_id.rs index 0a54ae57..383e9215 100644 --- a/core/src/peer_id.rs +++ b/core/src/peer_id.rs @@ -19,9 +19,10 @@ // DEALINGS IN THE SOFTWARE. use crate::PublicKey; +use bytes::Bytes; use bs58; use thiserror::Error; -use multihash::{self, Code, Multihash}; +use multihash::{Code, Multihash, MultihashDigest}; use rand::Rng; use std::{convert::TryFrom, borrow::Borrow, fmt, hash, str::FromStr, cmp}; @@ -35,7 +36,7 @@ const MAX_INLINE_KEY_LENGTH: usize = 42; // TODO: maybe keep things in decoded version? #[derive(Clone, Eq)] pub struct PeerId { - multihash: Multihash, + multihash: Bytes, } impl fmt::Debug for PeerId { @@ -78,7 +79,7 @@ impl PeerId { Code::Sha2_256 }; - let multihash = hash_algorithm.digest(&key_enc); + let multihash = hash_algorithm.digest(&key_enc).to_bytes().into(); PeerId { multihash } } @@ -86,9 +87,9 @@ impl PeerId { /// Checks whether `data` is a valid `PeerId`. If so, returns the `PeerId`. If not, returns /// back the data as an error. pub fn from_bytes(data: Vec) -> Result> { - match Multihash::from_bytes(data) { - Ok(multihash) => PeerId::from_multihash(multihash).map_err(Multihash::into_bytes), - Err(err) => Err(err.data), + match Multihash::from_bytes(&data) { + Ok(multihash) => PeerId::from_multihash(multihash).map_err(|_| data), + Err(_err) => Err(data), } } @@ -98,10 +99,10 @@ impl PeerId { /// or the hash value does not satisfy the constraints for a hashed /// peer ID, it is returned as an `Err`. pub fn from_multihash(multihash: Multihash) -> Result { - match multihash.algorithm() { - Code::Sha2_256 => Ok(PeerId { multihash }), - Code::Identity if multihash.digest().len() <= MAX_INLINE_KEY_LENGTH - => Ok(PeerId { multihash }), + match Code::try_from(multihash.code()) { + Ok(Code::Sha2_256) => Ok(PeerId { multihash: multihash.to_bytes().into() }), + Ok(Code::Identity) if multihash.digest().len() <= MAX_INLINE_KEY_LENGTH + => Ok(PeerId { multihash: multihash.to_bytes().into() }), _ => Err(multihash) } } @@ -112,7 +113,8 @@ impl PeerId { pub fn random() -> PeerId { let peer_id = rand::thread_rng().gen::<[u8; 32]>(); PeerId { - multihash: multihash::wrap(Code::Identity, &peer_id), + multihash: Multihash::wrap(Code::Identity.into(), &peer_id) + .expect("The digest size is never too large").to_bytes().into() } } @@ -122,7 +124,7 @@ impl PeerId { /// equality of peer IDs. That is, two peer IDs may be considered equal /// while having a different byte representation as per `into_bytes`. pub fn into_bytes(self) -> Vec { - self.multihash.into_bytes() + self.multihash.to_vec() } /// Returns a raw bytes representation of this `PeerId`. @@ -131,7 +133,7 @@ impl PeerId { /// equality of peer IDs. That is, two peer IDs may be considered equal /// while having a different byte representation as per `as_bytes`. pub fn as_bytes(&self) -> &[u8] { - self.multihash.as_bytes() + &self.multihash } /// Returns a base-58 encoded string of this `PeerId`. @@ -144,9 +146,12 @@ impl PeerId { /// Returns `None` if this `PeerId`s hash algorithm is not supported when encoding the /// given public key, otherwise `Some` boolean as the result of an equality check. pub fn is_public_key(&self, public_key: &PublicKey) -> Option { - let alg = self.multihash.algorithm(); + let multihash = Multihash::from_bytes(&self.multihash) + .expect("Internal multihash is always a valid"); + let alg = Code::try_from(multihash.code()) + .expect("Internal multihash is always a valid `Code`"); let enc = public_key.clone().into_protobuf_encoding(); - Some(alg.digest(&enc) == self.multihash) + Some(alg.digest(&enc) == multihash) } } @@ -192,7 +197,7 @@ impl PartialEq for PeerId { impl Borrow<[u8]> for PeerId { fn borrow(&self) -> &[u8] { - self.multihash.as_bytes() + &self.multihash } } @@ -207,7 +212,8 @@ impl AsRef<[u8]> for PeerId { impl From for Multihash { fn from(peer_id: PeerId) -> Self { - peer_id.multihash + Multihash::from_bytes(&peer_id.multihash) + .expect("PeerIds always contain valid Multihashes") } } diff --git a/misc/multiaddr/Cargo.toml b/misc/multiaddr/Cargo.toml index 8260d061..f69ad5f1 100644 --- a/misc/multiaddr/Cargo.toml +++ b/misc/multiaddr/Cargo.toml @@ -16,7 +16,7 @@ arrayref = "0.3" bs58 = "0.4.0" byteorder = "1.3.1" data-encoding = "2.1" -multihash = "0.11.3" +multihash = { version = "0.13", default-features = false, features = ["std"] } percent-encoding = "2.1.0" serde = "1.0.70" static_assertions = "1.1" diff --git a/misc/multiaddr/src/errors.rs b/misc/multiaddr/src/errors.rs index 964cdfff..245cea1c 100644 --- a/misc/multiaddr/src/errors.rs +++ b/misc/multiaddr/src/errors.rs @@ -51,8 +51,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: multihash::DecodeOwnedError) -> Error { +impl From for Error { + fn from(err: multihash::Error) -> Error { Error::ParsingError(err.into()) } } diff --git a/misc/multiaddr/src/protocol.rs b/misc/multiaddr/src/protocol.rs index 1ff0a8a6..14955452 100644 --- a/misc/multiaddr/src/protocol.rs +++ b/misc/multiaddr/src/protocol.rs @@ -156,7 +156,7 @@ impl<'a> Protocol<'a> { "p2p" => { let s = iter.next().ok_or(Error::InvalidProtocolString)?; let decoded = bs58::decode(s).into_vec()?; - Ok(Protocol::P2p(Multihash::from_bytes(decoded)?)) + Ok(Protocol::P2p(Multihash::from_bytes(&decoded)?)) } "http" => Ok(Protocol::Http), "https" => Ok(Protocol::Https), @@ -280,7 +280,7 @@ impl<'a> Protocol<'a> { P2P => { let (n, input) = decode::usize(input)?; let (data, rest) = split_at(n, input)?; - Ok((Protocol::P2p(Multihash::from_bytes(data.to_owned())?), rest)) + Ok((Protocol::P2p(Multihash::from_bytes(data)?), rest)) } P2P_CIRCUIT => Ok((Protocol::P2pCircuit, input)), QUIC => Ok((Protocol::Quic, input)), @@ -388,7 +388,7 @@ impl<'a> Protocol<'a> { } Protocol::P2p(multihash) => { w.write_all(encode::u32(P2P, &mut buf))?; - let bytes = multihash.as_bytes(); + let bytes = multihash.to_bytes(); w.write_all(encode::usize(bytes.len(), &mut encode::usize_buffer()))?; w.write_all(&bytes)? } @@ -492,7 +492,7 @@ impl<'a> fmt::Display for Protocol<'a> { let s = BASE32.encode(addr.hash()); write!(f, "/onion3/{}:{}", s.to_lowercase(), addr.port()) } - P2p(c) => write!(f, "/p2p/{}", bs58::encode(c.as_bytes()).into_string()), + P2p(c) => write!(f, "/p2p/{}", bs58::encode(c.to_bytes()).into_string()), P2pCircuit => f.write_str("/p2p-circuit"), Quic => f.write_str("/quic"), Sctp(port) => write!(f, "/sctp/{}", port), @@ -584,4 +584,4 @@ read_onion_impl!(read_onion, 10, 16); // Parse a version 3 onion address and return its binary representation. // // Format: ":" -read_onion_impl!(read_onion3, 35, 56); \ No newline at end of file +read_onion_impl!(read_onion3, 35, 56); diff --git a/misc/multiaddr/tests/lib.rs b/misc/multiaddr/tests/lib.rs index 1589ec27..55e22db1 100644 --- a/misc/multiaddr/tests/lib.rs +++ b/misc/multiaddr/tests/lib.rs @@ -140,7 +140,7 @@ fn ma_valid(source: &str, target: &str, protocols: Vec>) { } fn multihash(s: &str) -> Multihash { - Multihash::from_bytes(bs58::decode(s).into_vec().unwrap()).unwrap() + Multihash::from_bytes(&bs58::decode(s).into_vec().unwrap()).unwrap() } #[test] diff --git a/muxers/mplex/CHANGELOG.md b/muxers/mplex/CHANGELOG.md index 2277ae99..bd0a51fe 100644 --- a/muxers/mplex/CHANGELOG.md +++ b/muxers/mplex/CHANGELOG.md @@ -1,4 +1,6 @@ -# 0.24.1 [unreleased] +# 0.25.0 [unreleased] + +- Update `libp2p-core`. - Change the default `split_send_size` from 1KiB to 8KiB. [PR 1834](https://github.com/libp2p/rust-libp2p/pull/1834). diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index e6efc46a..40b3d2ae 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-mplex" edition = "2018" description = "Mplex multiplexing protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] bytes = "0.5" futures = "0.3.1" futures_codec = "0.4.1" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4" nohash-hasher = "0.2" parking_lot = "0.11" diff --git a/muxers/yamux/CHANGELOG.md b/muxers/yamux/CHANGELOG.md index 819b6782..4ced0719 100644 --- a/muxers/yamux/CHANGELOG.md +++ b/muxers/yamux/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.28.0 [unreleased] + +- Update `libp2p-core`. + # 0.27.0 [2020-11-09] - Tweak the naming in the `MplexConfig` API for better diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index eac6214e..7376495a 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-yamux" edition = "2018" description = "Yamux multiplexing protocol for libp2p" -version = "0.27.0" +version = "0.28.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } parking_lot = "0.11" thiserror = "1.0" yamux = "0.8.0" diff --git a/protocols/deflate/CHANGELOG.md b/protocols/deflate/CHANGELOG.md index 1741e693..34d0b196 100644 --- a/protocols/deflate/CHANGELOG.md +++ b/protocols/deflate/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/deflate/Cargo.toml b/protocols/deflate/Cargo.toml index de1d0760..b960433c 100644 --- a/protocols/deflate/Cargo.toml +++ b/protocols/deflate/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-deflate" edition = "2018" description = "Deflate encryption protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } flate2 = "1.0" [dev-dependencies] diff --git a/protocols/floodsub/CHANGELOG.md b/protocols/floodsub/CHANGELOG.md index 3995f183..696e02cd 100644 --- a/protocols/floodsub/CHANGELOG.md +++ b/protocols/floodsub/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 0ca72bc1..3b87710e 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-floodsub" edition = "2018" description = "Floodsub protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -13,8 +13,8 @@ categories = ["network-programming", "asynchronous"] cuckoofilter = "0.5.0" fnv = "1.0" futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } log = "0.4" prost = "0.6.1" rand = "0.7" diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 880b743e..7efabaa8 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index d70fe724..6f4c25b4 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-gossipsub" edition = "2018" description = "Gossipsub protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Age Manning "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -10,8 +10,8 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } bytes = "0.5.4" byteorder = "1.3.2" fnv = "1.0.6" diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index 0ae41665..03761672 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index d3125fe6..3606a3cb 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-identify" edition = "2018" description = "Nodes identifcation protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,8 +11,8 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } log = "0.4.1" prost = "0.6.1" smallvec = "1.0" diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 030d6f27..2d075e5e 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.26.0 [unreleased] + +- Update `libp2p-core` and `libp2p-swarm`. + # 0.25.0 [2020-11-09] - Upon newly established connections, delay routing table diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 68b4e9ad..2c23310e 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-kad" edition = "2018" description = "Kademlia protocol for libp2p" -version = "0.25.0" +version = "0.26.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -17,9 +17,8 @@ fnv = "1.0" futures_codec = "0.4" futures = "0.3.1" log = "0.4" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } -multihash = "0.11.3" +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } prost = "0.6.1" rand = "0.7.2" sha2 = "0.9.1" diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index d26f74a7..71fede97 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -38,7 +38,8 @@ use libp2p_core::{ identity, transport::MemoryTransport, multiaddr::{Protocol, Multiaddr, multiaddr}, - upgrade + upgrade, + multihash::{Code, Multihash, MultihashDigest}, }; use libp2p_noise as noise; use libp2p_swarm::Swarm; @@ -46,7 +47,6 @@ use libp2p_yamux as yamux; use quickcheck::*; use rand::{Rng, random, thread_rng, rngs::StdRng, SeedableRng}; use std::{collections::{HashSet, HashMap}, time::Duration, num::NonZeroUsize, u64}; -use multihash::{wrap, Code, Multihash}; type TestSwarm = Swarm>; @@ -129,7 +129,7 @@ fn build_fully_connected_nodes_with_config(total: usize, cfg: KademliaConfig) } fn random_multihash() -> Multihash { - wrap(Code::Sha2_256, &thread_rng().gen::<[u8; 32]>()) + Multihash::wrap(Code::Sha2_256.into(), &thread_rng().gen::<[u8; 32]>()).unwrap() } #[derive(Clone, Debug)] @@ -934,7 +934,7 @@ fn disjoint_query_does_not_finish_before_all_paths_did() { let mut trudy = build_node(); // Trudy the intrudor, an adversary. let mut bob = build_node(); - let key = Key::new(&multihash::Sha2_256::digest(&thread_rng().gen::<[u8; 32]>())); + let key = Key::from(Code::Sha2_256.digest(&thread_rng().gen::<[u8; 32]>())); let record_bob = Record::new(key.clone(), b"bob".to_vec()); let record_trudy = Record::new(key.clone(), b"trudy".to_vec()); diff --git a/protocols/kad/src/kbucket/key.rs b/protocols/kad/src/kbucket/key.rs index 2ec17a3f..56f4140b 100644 --- a/protocols/kad/src/kbucket/key.rs +++ b/protocols/kad/src/kbucket/key.rs @@ -19,8 +19,7 @@ // DEALINGS IN THE SOFTWARE. use uint::*; -use libp2p_core::PeerId; -use multihash::Multihash; +use libp2p_core::{PeerId, multihash::Multihash}; use sha2::{Digest, Sha256}; use sha2::digest::generic_array::{GenericArray, typenum::U32}; use std::borrow::Borrow; @@ -93,9 +92,13 @@ impl Into for Key { } impl From for Key { - fn from(m: Multihash) -> Self { - Key::new(m) - } + fn from(m: Multihash) -> Self { + let bytes = KeyBytes(Sha256::digest(&m.to_bytes())); + Key { + preimage: m, + bytes + } + } } impl From for Key { @@ -182,7 +185,7 @@ impl Distance { mod tests { use super::*; use quickcheck::*; - use multihash::{wrap, Code}; + use libp2p_core::multihash::Code; use rand::Rng; impl Arbitrary for Key { @@ -194,7 +197,7 @@ mod tests { impl Arbitrary for Key { fn arbitrary(_: &mut G) -> Key { let hash = rand::thread_rng().gen::<[u8; 32]>(); - Key::from(wrap(Code::Sha2_256, &hash)) + Key::from(Multihash::wrap(Code::Sha2_256.into(), &hash).unwrap()) } } diff --git a/protocols/kad/src/query/peers/closest.rs b/protocols/kad/src/query/peers/closest.rs index 6f3c4eea..87490212 100644 --- a/protocols/kad/src/query/peers/closest.rs +++ b/protocols/kad/src/query/peers/closest.rs @@ -466,15 +466,14 @@ enum PeerState { #[cfg(test)] mod tests { use super::*; - use libp2p_core::PeerId; + use libp2p_core::{PeerId, multihash::{Code, Multihash}}; use quickcheck::*; - use multihash::Multihash; use rand::{Rng, rngs::StdRng, SeedableRng}; use std::{iter, time::Duration}; fn random_peers(n: usize, g: &mut R) -> Vec { (0 .. n).map(|_| PeerId::from_multihash( - multihash::wrap(multihash::Code::Sha2_256, &g.gen::<[u8; 32]>()) + Multihash::wrap(Code::Sha2_256.into(), &g.gen::<[u8; 32]>()).unwrap() ).unwrap()).collect() } diff --git a/protocols/kad/src/query/peers/closest/disjoint.rs b/protocols/kad/src/query/peers/closest/disjoint.rs index 0bc176a8..70024440 100644 --- a/protocols/kad/src/query/peers/closest/disjoint.rs +++ b/protocols/kad/src/query/peers/closest/disjoint.rs @@ -432,6 +432,7 @@ mod tests { use super::*; use crate::K_VALUE; + use libp2p_core::multihash::{Code, Multihash}; use quickcheck::*; use rand::{Rng, seq::SliceRandom}; use std::collections::HashSet; @@ -526,7 +527,7 @@ mod tests { fn random_peers(n: usize, g: &mut R) -> Vec { (0 .. n).map(|_| PeerId::from_multihash( - multihash::wrap(multihash::Code::Sha2_256, &g.gen::<[u8; 32]>()) + Multihash::wrap(Code::Sha2_256.into(), &g.gen::<[u8; 32]>()).unwrap() ).unwrap()).collect() } diff --git a/protocols/kad/src/record.rs b/protocols/kad/src/record.rs index d00e27d9..a10240e6 100644 --- a/protocols/kad/src/record.rs +++ b/protocols/kad/src/record.rs @@ -23,8 +23,7 @@ pub mod store; use bytes::Bytes; -use libp2p_core::{PeerId, Multiaddr}; -use multihash::Multihash; +use libp2p_core::{PeerId, Multiaddr, multihash::Multihash}; use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use wasm_timer::Instant; @@ -65,7 +64,7 @@ impl From> for Key { impl From for Key { fn from(m: Multihash) -> Key { - Key::from(m.into_bytes()) + Key::from(m.to_bytes()) } } @@ -147,14 +146,14 @@ impl ProviderRecord { mod tests { use super::*; use quickcheck::*; - use multihash::{wrap, Code}; + use libp2p_core::multihash::Code; use rand::Rng; use std::time::Duration; impl Arbitrary for Key { fn arbitrary(_: &mut G) -> Key { let hash = rand::thread_rng().gen::<[u8; 32]>(); - Key::from(wrap(Code::Sha2_256, &hash)) + Key::from(Multihash::wrap(Code::Sha2_256.into(), &hash).unwrap()) } } diff --git a/protocols/kad/src/record/store/memory.rs b/protocols/kad/src/record/store/memory.rs index d4fdad79..6f2b95da 100644 --- a/protocols/kad/src/record/store/memory.rs +++ b/protocols/kad/src/record/store/memory.rs @@ -215,12 +215,12 @@ impl<'a> RecordStore<'a> for MemoryStore { #[cfg(test)] mod tests { use super::*; - use multihash::{wrap, Code}; + use libp2p_core::multihash::{Code, Multihash}; use quickcheck::*; use rand::Rng; fn random_multihash() -> Multihash { - wrap(Code::Sha2_256, &rand::thread_rng().gen::<[u8; 32]>()) + Multihash::wrap(Code::Sha2_256.into(), &rand::thread_rng().gen::<[u8; 32]>()).unwrap() } fn distance(r: &ProviderRecord) -> kbucket::Distance { diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index bebc82b6..1d2f6d59 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index f933a228..168a341e 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-mdns" edition = "2018" -version = "0.24.0" +version = "0.25.0" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" @@ -16,8 +16,8 @@ dns-parser = "0.8" either = "1.5.3" futures = "0.3.1" lazy_static = "1.2" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } log = "0.4" net2 = "0.2" rand = "0.7" diff --git a/protocols/mdns/src/service.rs b/protocols/mdns/src/service.rs index 4815a427..0d99c13d 100644 --- a/protocols/mdns/src/service.rs +++ b/protocols/mdns/src/service.rs @@ -589,7 +589,7 @@ mod tests { macro_rules! testgen { ($runtime_name:ident, $service_name:ty, $block_on_fn:tt) => { mod $runtime_name { - use libp2p_core::{PeerId, multiaddr::multihash}; + use libp2p_core::{PeerId, multihash::{Code, MultihashDigest}}; use std::time::Duration; use crate::service::MdnsPacket; @@ -683,7 +683,7 @@ mod tests { #[test] fn discover_long_peer_id() { let max_value = String::from_utf8(vec![b'f'; 42]).unwrap(); - let hash = multihash::Identity::digest(max_value.as_ref()); + let hash = Code::Identity.digest(max_value.as_ref()); discover(PeerId::from_multihash(hash).unwrap()) } } diff --git a/protocols/noise/CHANGELOG.md b/protocols/noise/CHANGELOG.md index 99818b7b..851a7022 100644 --- a/protocols/noise/CHANGELOG.md +++ b/protocols/noise/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.27.0 [unreleased] + +- Update `libp2p-core`. + # 0.26.0 [2020-11-09] - Update dependencies. diff --git a/protocols/noise/Cargo.toml b/protocols/noise/Cargo.toml index 22aae9dc..59b6f9ea 100644 --- a/protocols/noise/Cargo.toml +++ b/protocols/noise/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-noise" description = "Cryptographic handshake protocol using the noise framework." -version = "0.26.0" +version = "0.27.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,7 +12,7 @@ bytes = "0.5" curve25519-dalek = "3.0.0" futures = "0.3.1" lazy_static = "1.2" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4" prost = "0.6.1" rand = "0.7.2" diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index a393c52e..3f75fb1d 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 682ffe1d..3aa96f74 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-ping" edition = "2018" description = "Ping protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,8 +11,8 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } log = "0.4.1" rand = "0.7.2" void = "1.0" diff --git a/protocols/plaintext/CHANGELOG.md b/protocols/plaintext/CHANGELOG.md index c6047b7d..c6857f63 100644 --- a/protocols/plaintext/CHANGELOG.md +++ b/protocols/plaintext/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.1 [2020-11-11] - Ensure that no follow-up protocol data is dropped at the end of the diff --git a/protocols/plaintext/Cargo.toml b/protocols/plaintext/Cargo.toml index 54f174fd..017d2611 100644 --- a/protocols/plaintext/Cargo.toml +++ b/protocols/plaintext/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-plaintext" edition = "2018" description = "Plaintext encryption dummy protocol for libp2p" -version = "0.24.1" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] bytes = "0.5" futures = "0.3.1" futures_codec = "0.4.0" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.8" prost = "0.6.1" unsigned-varint = { version = "0.5.1", features = ["futures-codec"] } diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 7e70804a..198f1e6b 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.6.0 [unreleased] + +- Update `libp2p-swarm` and `libp2p-core`. + # 0.5.0 [2020-11-09] - Update dependencies. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 6e3a6052..89d97a6f 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-request-response" edition = "2018" description = "Generic Request/Response Protocols" -version = "0.5.0" +version = "0.6.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -13,8 +13,8 @@ categories = ["network-programming", "asynchronous"] async-trait = "0.1" bytes = "0.5.6" futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } -libp2p-swarm = { version = "0.24.0", path = "../../swarm" } +libp2p-core = { version = "0.25.0", path = "../../core" } +libp2p-swarm = { version = "0.25.0", path = "../../swarm" } log = "0.4.11" lru = "0.6" minicbor = { version = "0.7", features = ["std", "derive"] } diff --git a/protocols/secio/CHANGELOG.md b/protocols/secio/CHANGELOG.md index 9abfe808..6147c159 100644 --- a/protocols/secio/CHANGELOG.md +++ b/protocols/secio/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/protocols/secio/Cargo.toml b/protocols/secio/Cargo.toml index 88c817ae..fef7ae16 100644 --- a/protocols/secio/Cargo.toml +++ b/protocols/secio/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-secio" edition = "2018" description = "Secio encryption protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -19,7 +19,7 @@ ctr = "0.3" futures = "0.3.1" hmac = "0.9.0" lazy_static = "1.2.0" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.6" prost = "0.6.1" pin-project = "1.0.0" diff --git a/src/lib.rs b/src/lib.rs index df1b0ebd..8481a322 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,7 @@ pub use futures; #[doc(inline)] pub use multiaddr; #[doc(inline)] -pub use multihash; +pub use libp2p_core::multihash; #[doc(inline)] pub use libp2p_core as core; diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index cf727919..2c2b0d35 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 3da31da1..ca527aab 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-swarm" edition = "2018" description = "The libp2p swarm" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1.6.0" futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../core" } +libp2p-core = { version = "0.25.0", path = "../core" } log = "0.4" rand = "0.7" smallvec = "1.0" diff --git a/transports/dns/CHANGELOG.md b/transports/dns/CHANGELOG.md index f0a9481e..5a324eea 100644 --- a/transports/dns/CHANGELOG.md +++ b/transports/dns/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index bb8f8b50..405edfe2 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-dns" edition = "2018" description = "DNS transport implementation for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -10,6 +10,6 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.1" futures = "0.3.1" diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index 8f7e865f..4df28deb 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 7ea23a53..d21f3ac7 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-tcp" edition = "2018" description = "TCP/IP transport protocol for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -15,7 +15,7 @@ futures = "0.3.1" futures-timer = "3.0" if-addrs = "0.6.4" ipnet = "2.0.0" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.1" socket2 = { version = "0.3.12" } tokio = { version = "0.3", default-features = false, features = ["net"], optional = true } diff --git a/transports/uds/CHANGELOG.md b/transports/uds/CHANGELOG.md index 893614cc..3efa3d1c 100644 --- a/transports/uds/CHANGELOG.md +++ b/transports/uds/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Update dependencies. diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 0df652ce..825ecafc 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-uds" edition = "2018" description = "Unix domain sockets transport for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"] [target.'cfg(all(unix, not(target_os = "emscripten")))'.dependencies] async-std = { version = "1.6.2", optional = true } -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.1" futures = "0.3.1" tokio = { version = "0.3", default-features = false, features = ["net"], optional = true } diff --git a/transports/wasm-ext/CHANGELOG.md b/transports/wasm-ext/CHANGELOG.md index dfdafbb6..54c4ef13 100644 --- a/transports/wasm-ext/CHANGELOG.md +++ b/transports/wasm-ext/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.25.0 [unreleased] + +- Update `libp2p-core`. + # 0.24.0 [2020-11-09] - Fix the WebSocket implementation parsing `x-parity-ws` multiaddresses as `x-parity-wss`. diff --git a/transports/wasm-ext/Cargo.toml b/transports/wasm-ext/Cargo.toml index ca47b8dc..c21d15a6 100644 --- a/transports/wasm-ext/Cargo.toml +++ b/transports/wasm-ext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-wasm-ext" -version = "0.24.0" +version = "0.25.0" authors = ["Pierre Krieger "] edition = "2018" description = "Allows passing in an external transport in a WASM environment" @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.1" js-sys = "0.3.19" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } parity-send-wrapper = "0.1.0" wasm-bindgen = "0.2.42" wasm-bindgen-futures = "0.4.4" diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index 650039dc..245a98ad 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.26.0 [unreleased] + +- Update `libp2p-core`. + # 0.25.0 [2020-11-09] - Update dependencies. diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index d5e9c843..1390af06 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-websocket" edition = "2018" description = "WebSocket transport for libp2p" -version = "0.25.0" +version = "0.26.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] async-tls = "0.10.0" either = "1.5.3" futures = "0.3.1" -libp2p-core = { version = "0.24.0", path = "../../core" } +libp2p-core = { version = "0.25.0", path = "../../core" } log = "0.4.8" quicksink = "0.1" rustls = "0.18.0"