Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into brahms
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Jan 31, 2019
2 parents 8b0dc36 + fcb2ac3 commit daef5b5
Show file tree
Hide file tree
Showing 83 changed files with 2,155 additions and 281 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Version 0.3.0 (2019-01-30)

- Removed the `topology` module and everything it contained, including the `Topology` trait.
- Added `libp2p-noise` that supports Noise handshakes, as an alternative to `libp2p-secio`.
- Updated `ring` to version 0.14.
- Creating a `Swarm` now expects the `PeerId` of the local node, instead of a `Topology`.
- Added `NetworkBehaviour::addresses_of_peer` that returns the addresses a `NetworkBehaviour` knows about a given peer. This exists as a replacement for the topology.
- The `Kademlia` and `Mdns` behaviours now report and store the list of addresses they discover.
- You must now call `Floodsub::add_node_to_partial_view()` and `Floodsub::remove_node_from_partial_view` to add/remove nodes from the list of nodes that floodsub must send messages to.
- Added `NetworkBehaviour::inject_dial_failure` that is called when we fail to dial an address.
- `ProtocolsHandler::connection_keep_alive()` now returns a `KeepAlive` enum that provides more fine grained control.
- The `NodeHandlerWrapper` no longer has a 5 seconds inactivity timeout. This is now handled entirely by `ProtocolsHandler::connection_keep_alive()`.
- Now properly denying connections incoming from the same `PeerId` as ours.
- Added a `SwarmBuilder`. The `incoming_limit` method lets you configure the number of simultaneous incoming connections.
- Removed `FloodsubHandler`, `PingListenHandler` and `PeriodicPingHandler`.
- The structs in `core::nodes` are now generic over the `PeerId`.
- Added `SecioKeypair::ed25519_raw_key()`.
- Fix improper connection shutdown in `ProtocolsHandler`.

# Version 0.2.2 (2019-01-14)

- Fixed improper dependencies versions causing deriving `NetworkBehaviour` to generate an error.
Expand Down
36 changes: 19 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p"
edition = "2018"
description = "Peer-to-peer networking library"
version = "0.2.2"
version = "0.3.0"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -19,27 +19,28 @@ futures = "0.1"
multiaddr = { package = "parity-multiaddr", version = "0.1.0", path = "./misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "./misc/multihash" }
libp2p-brahms = { version = "0.1.0", path = "./protocols/brahms" }
libp2p-mplex = { version = "0.2.0", path = "./muxers/mplex" }
libp2p-identify = { version = "0.2.0", path = "./protocols/identify" }
libp2p-kad = { version = "0.2.0", path = "./protocols/kad" }
libp2p-floodsub = { version = "0.2.0", path = "./protocols/floodsub" }
libp2p-ping = { version = "0.2.0", path = "./protocols/ping" }
libp2p-plaintext = { version = "0.2.0", path = "./protocols/plaintext" }
libp2p-ratelimit = { version = "0.2.0", path = "./transports/ratelimit" }
libp2p-core = { version = "0.2.1", path = "./core" }
libp2p-core-derive = { version = "0.2.1", path = "./misc/core-derive" }
libp2p-secio = { version = "0.2.0", path = "./protocols/secio", default-features = false }
libp2p-uds = { version = "0.2.0", path = "./transports/uds" }
libp2p-websocket = { version = "0.2.0", path = "./transports/websocket", optional = true }
libp2p-yamux = { version = "0.2.0", path = "./muxers/yamux" }
libp2p-mplex = { version = "0.3.0", path = "./muxers/mplex" }
libp2p-identify = { version = "0.3.0", path = "./protocols/identify" }
libp2p-kad = { version = "0.3.0", path = "./protocols/kad" }
libp2p-floodsub = { version = "0.3.0", path = "./protocols/floodsub" }
libp2p-ping = { version = "0.3.0", path = "./protocols/ping" }
libp2p-plaintext = { version = "0.3.0", path = "./protocols/plaintext" }
libp2p-ratelimit = { version = "0.3.0", path = "./transports/ratelimit" }
libp2p-core = { version = "0.3.0", path = "./core" }
libp2p-core-derive = { version = "0.3.0", path = "./misc/core-derive" }
libp2p-secio = { version = "0.3.0", path = "./protocols/secio", default-features = false }
libp2p-uds = { version = "0.3.0", path = "./transports/uds" }
libp2p-websocket = { version = "0.3.0", path = "./transports/websocket", optional = true }
libp2p-yamux = { version = "0.3.0", path = "./muxers/yamux" }
tokio-codec = "0.1"
tokio-executor = "0.1"
tokio-io = "0.1"

[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
libp2p-dns = { version = "0.2.0", path = "./transports/dns" }
libp2p-mdns = { version = "0.2.0", path = "./misc/mdns" }
libp2p-tcp = { version = "0.2.0", path = "./transports/tcp" }
libp2p-dns = { version = "0.3.0", path = "./transports/dns" }
libp2p-mdns = { version = "0.3.0", path = "./misc/mdns" }
libp2p-noise = { version = "0.1.0", path = "./protocols/noise" }
libp2p-tcp = { version = "0.3.0", path = "./transports/tcp" }

[target.'cfg(any(target_os = "emscripten", target_os = "unknown"))'.dependencies]
stdweb = { version = "0.4", default-features = false }
Expand Down Expand Up @@ -67,6 +68,7 @@ members = [
"protocols/floodsub",
"protocols/identify",
"protocols/kad",
"protocols/noise",
"protocols/observed",
"protocols/ping",
"protocols/plaintext",
Expand Down
12 changes: 6 additions & 6 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-core"
edition = "2018"
description = "Core traits and structs of libp2p"
version = "0.2.1"
version = "0.3.0"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -16,10 +16,10 @@ fnv = "1.0"
log = "0.4"
multiaddr = { package = "parity-multiaddr", version = "0.1.0", path = "../misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "../misc/multihash" }
multistream-select = { version = "0.2.0", path = "../misc/multistream-select" }
multistream-select = { version = "0.3.0", path = "../misc/multistream-select" }
futures = { version = "0.1", features = ["use_std"] }
parking_lot = "0.7"
protobuf = "2.0.2"
protobuf = "2.3"
quick-error = "1.2"
rw-stream-sink = { version = "0.1.0", path = "../misc/rw-stream-sink" }
smallvec = "0.6"
Expand All @@ -30,9 +30,9 @@ unsigned-varint = "0.2"
void = "1"

[dev-dependencies]
libp2p-ping = { version = "0.2.0", path = "../protocols/ping" }
libp2p-tcp = { version = "0.2.0", path = "../transports/tcp" }
libp2p-mplex = { version = "0.2.0", path = "../muxers/mplex" }
libp2p-ping = { version = "0.3.0", path = "../protocols/ping" }
libp2p-tcp = { version = "0.3.0", path = "../transports/tcp" }
libp2p-mplex = { version = "0.3.0", path = "../muxers/mplex" }
rand = "0.6"
tokio = "0.1"
tokio-codec = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion core/regen_structs_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sudo docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \
apt-get update; \
apt-get install -y protobuf-compiler; \
cargo install --version 2.0.2 protobuf-codegen; \
cargo install --version 2.3.0 protobuf-codegen; \
protoc --rust_out . keys.proto"

sudo chown $USER:$USER keys.rs
Expand Down
4 changes: 2 additions & 2 deletions core/src/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ where
match self {
EitherFuture2::A(a) => a.poll()
.map(|v| v.map(EitherOutput::First))
.map_err(|e| EitherError::A(e)),
.map_err(EitherError::A),

EitherFuture2::B(b) => b.poll()
.map(|v| v.map(EitherOutput::Second))
.map_err(|e| EitherError::B(e))
.map_err(EitherError::B)
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions core/src/keys_proto.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// This file is generated by rust-protobuf 2.0.2. Do not edit
// This file is generated by rust-protobuf 2.3.0. Do not edit
// @generated

// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy)]
#![allow(clippy::all)]

#![cfg_attr(rustfmt, rustfmt_skip)]

Expand All @@ -27,8 +27,8 @@ pub struct PublicKey {
Type: ::std::option::Option<KeyType>,
Data: ::protobuf::SingularField<::std::vec::Vec<u8>>,
// special fields
unknown_fields: ::protobuf::UnknownFields,
cached_size: ::protobuf::CachedSize,
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}

impl PublicKey {
Expand Down Expand Up @@ -241,8 +241,8 @@ pub struct PrivateKey {
Type: ::std::option::Option<KeyType>,
Data: ::protobuf::SingularField<::std::vec::Vec<u8>>,
// special fields
unknown_fields: ::protobuf::UnknownFields,
cached_size: ::protobuf::CachedSize,
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}

impl PrivateKey {
Expand Down Expand Up @@ -495,6 +495,12 @@ impl ::protobuf::ProtobufEnum for KeyType {
impl ::std::marker::Copy for KeyType {
}

impl ::std::default::Default for KeyType {
fn default() -> Self {
KeyType::RSA
}
}

impl ::protobuf::reflect::ProtobufValue for KeyType {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())
Expand Down
2 changes: 1 addition & 1 deletion core/src/nodes/handled_node_tasks/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl NodeTaskTestBuilder {
}
};
let node_task = NodeTask {
inner: inner,
inner,
events_tx: events_from_node_task_tx.clone(), // events TO the outside
in_events_rx: events_to_node_task_rx.fuse(), // events FROM the outside
id: self.task_id,
Expand Down
14 changes: 7 additions & 7 deletions core/src/nodes/raw_swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ where
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
RawSwarmEvent::ListenerClosed { ref listen_addr, listener: _, ref result } => {
RawSwarmEvent::ListenerClosed { ref listen_addr, ref result, .. } => {
f.debug_struct("ListenerClosed")
.field("listen_addr", listen_addr)
.field("result", result)
Expand Down Expand Up @@ -1327,7 +1327,7 @@ where
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Peer::Connected( PeerConnected { peer: _, ref peer_id, ref connected_points }) => {
Peer::Connected( PeerConnected { ref peer_id, ref connected_points, .. }) => {
f.debug_struct("Connected")
.field("peer_id", peer_id)
.field("connected_points", connected_points)
Expand Down Expand Up @@ -1371,7 +1371,7 @@ where
{
/// If we are connected, returns the `PeerConnected`.
#[inline]
pub fn as_connected(self) -> Option<PeerConnected<'a, TInEvent, TPeerId>> {
pub fn into_connected(self) -> Option<PeerConnected<'a, TInEvent, TPeerId>> {
match self {
Peer::Connected(peer) => Some(peer),
_ => None,
Expand All @@ -1380,7 +1380,7 @@ where

/// If a connection is pending, returns the `PeerPendingConnect`.
#[inline]
pub fn as_pending_connect(self) -> Option<PeerPendingConnect<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
pub fn into_pending_connect(self) -> Option<PeerPendingConnect<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
match self {
Peer::PendingConnect(peer) => Some(peer),
_ => None,
Expand All @@ -1389,7 +1389,7 @@ where

/// If we are not connected, returns the `PeerNotConnected`.
#[inline]
pub fn as_not_connected(self) -> Option<PeerNotConnected<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
pub fn into_not_connected(self) -> Option<PeerNotConnected<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
match self {
Peer::NotConnected(peer) => Some(peer),
_ => None,
Expand Down Expand Up @@ -1464,7 +1464,7 @@ where

/// If we are connected, returns the `PeerConnected`.
#[inline]
pub fn as_connected(self) -> Option<PeerConnected<'a, TInEvent, TPeerId>> {
pub fn into_connected(self) -> Option<PeerConnected<'a, TInEvent, TPeerId>> {
match self {
PeerPotentialConnect::Connected(peer) => Some(peer),
_ => None,
Expand All @@ -1473,7 +1473,7 @@ where

/// If a connection is pending, returns the `PeerPendingConnect`.
#[inline]
pub fn as_pending_connect(self) -> Option<PeerPendingConnect<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
pub fn into_pending_connect(self) -> Option<PeerPendingConnect<'a, TTrans, TInEvent, TOutEvent, THandler, THandlerErr, TPeerId>> {
match self {
PeerPotentialConnect::PendingConnect(peer) => Some(peer),
_ => None,
Expand Down
12 changes: 6 additions & 6 deletions core/src/nodes/raw_swarm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn num_incoming_negotiated() {
swarm.listen_on("/memory".parse().unwrap()).unwrap();

// no incoming yet
assert_eq!(swarm.num_incoming_negotiated(), 0);
assert_eq!(swarm.incoming_negotiated().count(), 0);

let mut rt = Runtime::new().unwrap();
let swarm = Arc::new(Mutex::new(swarm));
Expand All @@ -147,7 +147,7 @@ fn num_incoming_negotiated() {
rt.block_on(fut).expect("tokio works");
let swarm = swarm.lock();
// Now there's an incoming connection
assert_eq!(swarm.num_incoming_negotiated(), 1);
assert_eq!(swarm.incoming_negotiated().count(), 1);
}

#[test]
Expand Down Expand Up @@ -204,7 +204,7 @@ fn querying_for_pending_peer() {
let peer = swarm.peer(peer_id.clone());
assert_matches!(peer, Peer::NotConnected(PeerNotConnected{ .. }));
let addr = "/memory".parse().expect("bad multiaddr");
let pending_peer = peer.as_not_connected().unwrap().connect(addr, Handler::default());
let pending_peer = peer.into_not_connected().unwrap().connect(addr, Handler::default());
assert_matches!(pending_peer, PeerPendingConnect { .. });
}

Expand Down Expand Up @@ -312,7 +312,7 @@ fn known_peer_that_is_unreachable_yields_dial_error() {
let peer = swarm1.peer(peer_id.clone());
assert_matches!(peer, Peer::NotConnected(PeerNotConnected{ .. }));
let addr = "/memory".parse::<Multiaddr>().expect("bad multiaddr");
let pending_peer = peer.as_not_connected().unwrap().connect(addr, Handler::default());
let pending_peer = peer.into_not_connected().unwrap().connect(addr, Handler::default());
assert_matches!(pending_peer, PeerPendingConnect { .. });
}
let mut rt = Runtime::new().unwrap();
Expand Down Expand Up @@ -354,7 +354,7 @@ fn yields_node_error_when_there_is_an_error_after_successful_connect() {
let mut handler = Handler::default();
// Force an error
handler.next_states = vec![ HandlerState::Err ];
peer.as_not_connected().unwrap().connect(addr, handler);
peer.into_not_connected().unwrap().connect(addr, handler);
}

// Ensure we run on a single thread
Expand Down Expand Up @@ -408,7 +408,7 @@ fn yields_node_closed_when_the_node_closes_after_successful_connect() {
let mut handler = Handler::default();
// Force handler to close
handler.next_states = vec![ HandlerState::Ready(None) ];
peer.as_not_connected().unwrap().connect(addr, handler);
peer.into_not_connected().unwrap().connect(addr, handler);
}

// Ensure we run on a single thread
Expand Down
4 changes: 2 additions & 2 deletions core/src/protocols_handler/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// DEALINGS IN THE SOFTWARE.

use crate::{
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
protocols_handler::{KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
upgrade::{
InboundUpgrade,
OutboundUpgrade,
Expand Down Expand Up @@ -89,7 +89,7 @@ where
fn inject_inbound_closed(&mut self) {}

#[inline]
fn connection_keep_alive(&self) -> bool { false }
fn connection_keep_alive(&self) -> KeepAlive { KeepAlive::Now }

#[inline]
fn shutdown(&mut self) {
Expand Down
Loading

0 comments on commit daef5b5

Please sign in to comment.