Skip to content

Commit

Permalink
Merge branch 'master' into check-multiaddr-has-correct-peer-or-none-a…
Browse files Browse the repository at this point in the history
…t-all
  • Loading branch information
MarcoPolo committed Nov 15, 2021
2 parents f6025da + 220f84a commit 27340f8
Show file tree
Hide file tree
Showing 57 changed files with 724 additions and 447 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- uses: Swatinem/rust-cache@v1.3.0
with:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- name: Install Rust ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1.0.7
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- uses: Swatinem/rust-cache@v1.3.0

Expand All @@ -109,7 +109,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- uses: actions-rs/toolchain@v1.0.7
with:
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- uses: Swatinem/rust-cache@v1.3.0

Expand All @@ -153,7 +153,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- uses: actions-rs/toolchain@v1.0.7
with:
Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
lazy_static = "1.2"
libp2p-core = { version = "0.30.0", path = "core", default-features = false }
libp2p-floodsub = { version = "0.31.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.33.0", path = "./protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.31.0", path = "protocols/identify", optional = true }
libp2p-floodsub = { version = "0.32.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.34.0", path = "./protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.32.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.33.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.1.0", path = "misc/metrics", optional = true }
libp2p-metrics = { version = "0.2.0", path = "misc/metrics", optional = true }
libp2p-mplex = { version = "0.30.0", path = "muxers/mplex", optional = true }
libp2p-noise = { version = "0.33.0", path = "transports/noise", optional = true }
libp2p-ping = { version = "0.31.0", path = "protocols/ping", optional = true }
libp2p-ping = { version = "0.32.0", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.30.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.0", path = "transports/pnet", optional = true }
libp2p-relay = { version = "0.4.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.1.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.13.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.31.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.25.0", path = "swarm-derive" }
libp2p-relay = { version = "0.5.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.2.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.14.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.32.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.26.0", path = "swarm-derive" }
libp2p-uds = { version = "0.30.0", path = "transports/uds", optional = true }
libp2p-wasm-ext = { version = "0.30.0", path = "transports/wasm-ext", default-features = false, optional = true }
libp2p-yamux = { version = "0.34.0", path = "muxers/yamux", optional = true }
Expand All @@ -99,7 +99,7 @@ smallvec = "1.6.1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
libp2p-deflate = { version = "0.30.0", path = "transports/deflate", optional = true }
libp2p-dns = { version = "0.30.0", path = "transports/dns", optional = true, default-features = false }
libp2p-mdns = { version = "0.32.0", path = "protocols/mdns", optional = true }
libp2p-mdns = { version = "0.33.0", path = "protocols/mdns", optional = true }
libp2p-tcp = { version = "0.30.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.32.0", path = "transports/websocket", optional = true }

Expand Down
4 changes: 2 additions & 2 deletions examples/chat-tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use libp2p::{
mdns::{Mdns, MdnsEvent},
mplex,
noise,
swarm::{NetworkBehaviourEventProcess, SwarmBuilder, SwarmEvent},
swarm::{dial_opts::DialOpts, NetworkBehaviourEventProcess, SwarmBuilder, SwarmEvent},
// `TokioTcpConfig` is available through the `tcp-tokio` feature.
tcp::TokioTcpConfig,
Multiaddr,
Expand Down Expand Up @@ -148,7 +148,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// Reach out to another node if specified
if let Some(to_dial) = std::env::args().nth(1) {
let addr: Multiaddr = to_dial.parse()?;
swarm.dial_addr(addr)?;
swarm.dial(addr)?;
println!("Dialed {:?}", to_dial)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// Reach out to another node if specified
if let Some(to_dial) = std::env::args().nth(1) {
let addr: Multiaddr = to_dial.parse()?;
swarm.dial_addr(addr)?;
swarm.dial(addr)?;
println!("Dialed {:?}", to_dial)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/file-sharing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ mod network {
.add_address(&peer_id, peer_addr.clone());
match self
.swarm
.dial_addr(peer_addr.with(Protocol::P2p(peer_id.into())))
.dial(peer_addr.with(Protocol::P2p(peer_id.into())))
{
Ok(()) => {
self.pending_dial.insert(peer_id, sender);
Expand Down
15 changes: 6 additions & 9 deletions examples/gossipsub-chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use libp2p::gossipsub::MessageId;
use libp2p::gossipsub::{
GossipsubEvent, GossipsubMessage, IdentTopic as Topic, MessageAuthenticity, ValidationMode,
};
use libp2p::{gossipsub, identity, swarm::SwarmEvent, PeerId};
use libp2p::{gossipsub, identity, swarm::SwarmEvent, Multiaddr, PeerId};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::time::Duration;
Expand Down Expand Up @@ -122,14 +122,11 @@ async fn main() -> Result<(), Box<dyn Error>> {

// Reach out to another node if specified
if let Some(to_dial) = std::env::args().nth(1) {
let dialing = to_dial.clone();
match to_dial.parse() {
Ok(to_dial) => match swarm.dial_addr(to_dial) {
Ok(_) => println!("Dialed {:?}", dialing),
Err(e) => println!("Dial {:?} failed: {:?}", dialing, e),
},
Err(err) => println!("Failed to parse address to dial: {:?}", err),
}
let address: Multiaddr = to_dial.parse().expect("User to provide valid address.");
match swarm.dial(address.clone()) {
Ok(_) => println!("Dialed {:?}", address),
Err(e) => println!("Dial {:?} failed: {:?}", address, e),
};
}

// Read full lines from stdin
Expand Down
2 changes: 1 addition & 1 deletion examples/ipfs-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Reach out to other nodes if specified
for to_dial in std::env::args().skip(1) {
let addr: Multiaddr = parse_legacy_multiaddr(&to_dial)?;
swarm.dial_addr(addr)?;
swarm.dial(addr)?;
println!("Dialed {:?}", to_dial)
}

Expand Down
6 changes: 3 additions & 3 deletions examples/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
use futures::executor::block_on;
use futures::prelude::*;
use libp2p::swarm::{Swarm, SwarmEvent};
use libp2p::{identity, ping, PeerId};
use libp2p::{identity, ping, Multiaddr, PeerId};
use std::error::Error;
use std::task::Poll;

Expand All @@ -70,8 +70,8 @@ fn main() -> Result<(), Box<dyn Error>> {
// Dial the peer identified by the multi-address given as the second
// command-line argument, if any.
if let Some(addr) = std::env::args().nth(1) {
let remote = addr.parse()?;
swarm.dial_addr(remote)?;
let remote: Multiaddr = addr.parse()?;
swarm.dial(remote)?;
println!("Dialed {}", addr)
}

Expand Down
4 changes: 4 additions & 0 deletions misc/metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.2.0 [unreleased]

- Update dependencies.

## Version 0.1.0 [2021-11-01]

- Add initial version.
12 changes: 6 additions & 6 deletions misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-metrics"
edition = "2018"
description = "Metrics for libp2p"
version = "0.1.0"
version = "0.2.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -15,11 +15,11 @@ kad = ["libp2p-kad"]
ping = ["libp2p-ping"]

[dependencies]
libp2p-core= { version = "0.30.0", path = "../../core" }
libp2p-identify = { version = "0.31.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.33.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.31.0", path = "../../protocols/ping", optional = true }
libp2p-swarm = { version = "0.31.0", path = "../../swarm" }
libp2p-core = { version = "0.30.0", path = "../../core" }
libp2p-identify = { version = "0.32.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.33.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.32.0", path = "../../protocols/ping", optional = true }
libp2p-swarm = { version = "0.32.0", path = "../../swarm" }
open-metrics-client = "0.12.0"

[dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions misc/metrics/examples/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

use futures::executor::block_on;
use futures::stream::StreamExt;
use libp2p::core::Multiaddr;
use libp2p::metrics::{Metrics, Recorder};
use libp2p::ping::{Ping, PingConfig};
use libp2p::swarm::SwarmEvent;
Expand All @@ -74,8 +75,8 @@ fn main() -> Result<(), Box<dyn Error>> {
);
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
if let Some(addr) = std::env::args().nth(1) {
let remote = addr.parse()?;
swarm.dial_addr(remote)?;
let remote: Multiaddr = addr.parse()?;
swarm.dial(remote)?;
tide::log::info!("Dialed {}", addr)
}

Expand Down
4 changes: 4 additions & 0 deletions protocols/floodsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.32.0 [unreleased]

- Update dependencies.

# 0.31.0 [2021-11-01]

- Make default features of `libp2p-core` optional.
Expand Down
4 changes: 2 additions & 2 deletions protocols/floodsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-floodsub"
edition = "2018"
description = "Floodsub protocol for libp2p"
version = "0.31.0"
version = "0.32.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -14,7 +14,7 @@ cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.30.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.31.0", path = "../../swarm" }
libp2p-swarm = { version = "0.32.0", path = "../../swarm" }
log = "0.4"
prost = "0.9"
rand = "0.7"
Expand Down
18 changes: 10 additions & 8 deletions protocols/floodsub/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use cuckoofilter::{CuckooError, CuckooFilter};
use fnv::FnvHashSet;
use libp2p_core::{connection::ConnectionId, PeerId};
use libp2p_swarm::{
DialPeerCondition, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler,
PollParameters,
dial_opts::{self, DialOpts},
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler, PollParameters,
};
use log::warn;
use smallvec::SmallVec;
Expand Down Expand Up @@ -107,9 +107,10 @@ impl Floodsub {

if self.target_peers.insert(peer_id) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::DialPeer {
peer_id,
condition: DialPeerCondition::Disconnected,
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
});
}
Expand Down Expand Up @@ -310,9 +311,10 @@ impl NetworkBehaviour for Floodsub {
// try to reconnect.
if self.target_peers.contains(id) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::DialPeer {
peer_id: *id,
condition: DialPeerCondition::Disconnected,
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(*id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
});
}
Expand Down
4 changes: 3 additions & 1 deletion protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# 0.33.1 [unreleased]
# 0.34.0 [unreleased]

- Fix bug in internal peer's topics tracking (see [PR 2325]).

- Use `instant` and `futures-timer` instead of `wasm-timer` (see [PR 2245]).

- Update dependencies.

[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
[PR 2325]: https://github.com/libp2p/rust-libp2p/pull/2325

Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name = "libp2p-gossipsub"
edition = "2018"
description = "Gossipsub protocol for libp2p"
version = "0.33.1"
version = "0.34.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[dependencies]
libp2p-swarm = { version = "0.31.0", path = "../../swarm" }
libp2p-swarm = { version = "0.32.0", path = "../../swarm" }
libp2p-core = { version = "0.30.0", path = "../../core", default-features = false }
bytes = "1.0"
byteorder = "1.3.4"
Expand Down
18 changes: 10 additions & 8 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ use libp2p_core::{
multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId,
};
use libp2p_swarm::{
DialPeerCondition, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction,
NotifyHandler, PollParameters,
dial_opts::{self, DialOpts},
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
};

use crate::config::{GossipsubConfig, ValidationMode};
Expand Down Expand Up @@ -1046,9 +1046,10 @@ where
// Connect to peer
debug!("Connecting to explicit peer {:?}", peer_id);
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::DialPeer {
peer_id: *peer_id,
condition: DialPeerCondition::Disconnected,
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(*peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
});
}
Expand Down Expand Up @@ -1502,9 +1503,10 @@ where

// dial peer
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::DialPeer {
peer_id,
condition: DialPeerCondition::Disconnected,
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
});
}
Expand Down

0 comments on commit 27340f8

Please sign in to comment.