Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/gossipsub-chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use env_logger::{Builder, Env};
use futures::prelude::*;
use libp2p::gossipsub::MessageId;
use libp2p::gossipsub::{
GossipsubEvent, IdentTopic as Topic, MessageAuthenticity, RawGossipsubMessage, ValidationMode,
GossipsubEvent, GossipsubMessage, IdentTopic as Topic, MessageAuthenticity, ValidationMode,
};
use libp2p::{gossipsub, identity, PeerId};
use std::collections::hash_map::DefaultHasher;
Expand Down Expand Up @@ -79,7 +79,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Create a Swarm to manage peers and events
let mut swarm = {
// To content-address message, we can take the hash of message and use it as an ID.
let message_id_fn = |message: &RawGossipsubMessage| {
let message_id_fn = |message: &GossipsubMessage| {
let mut s = DefaultHasher::new();
message.data.hash(&mut s);
MessageId::from(s.finish().to_string())
Expand All @@ -94,7 +94,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.build()
.expect("Valid config");
// build a gossipsub network behaviour
let mut gossipsub =
let mut gossipsub: gossipsub::Gossipsub =
gossipsub::Gossipsub::new(MessageAuthenticity::Signed(local_key), gossipsub_config)
.expect("Correct configuration");

Expand Down Expand Up @@ -154,7 +154,7 @@ fn main() -> Result<(), Box<dyn Error>> {
message,
} => println!(
"Got message: {} with id: {} from peer: {:?}",
String::from_utf8_lossy(message.data()),
String::from_utf8_lossy(&message.data),
id,
peer_id
),
Expand Down
15 changes: 9 additions & 6 deletions examples/ipfs-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
use async_std::{io, task};
use futures::{future, prelude::*};
use libp2p::{
core::{either::EitherTransport, transport, transport::upgrade::Version, muxing::StreamMuxerBox},
core::{
either::EitherTransport, muxing::StreamMuxerBox, transport, transport::upgrade::Version,
},
gossipsub::{self, Gossipsub, GossipsubConfigBuilder, GossipsubEvent, MessageAuthenticity},
identify::{Identify, IdentifyEvent},
identity,
multiaddr::Protocol,
noise,
ping::{self, Ping, PingConfig, PingEvent},
pnet::{PnetConfig, PreSharedKey},
noise,
swarm::NetworkBehaviourEventProcess,
tcp::TcpConfig,
yamux::YamuxConfig,
Expand All @@ -61,9 +63,10 @@ use std::{
pub fn build_transport(
key_pair: identity::Keypair,
psk: Option<PreSharedKey>,
) -> transport::Boxed<(PeerId, StreamMuxerBox)>
{
let noise_keys = noise::Keypair::<noise::X25519Spec>::new().into_authentic(&key_pair).unwrap();
) -> transport::Boxed<(PeerId, StreamMuxerBox)> {
let noise_keys = noise::Keypair::<noise::X25519Spec>::new()
.into_authentic(&key_pair)
.unwrap();
let noise_config = noise::NoiseConfig::xx(noise_keys).into_authenticated();
let yamux_config = YamuxConfig::default();

Expand Down Expand Up @@ -184,7 +187,7 @@ fn main() -> Result<(), Box<dyn Error>> {
message,
} => println!(
"Got message: {} with id: {} from peer: {:?}",
String::from_utf8_lossy(message.data()),
String::from_utf8_lossy(&message.data),
id,
peer_id
),
Expand Down
2 changes: 2 additions & 0 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ categories = ["network-programming", "asynchronous"]

[features]
regex-filter = ["regex"]
snappy = ["snap"]
default = []

[dependencies]
Expand All @@ -31,6 +32,7 @@ smallvec = "1.4.2"
prost = "0.6.1"
hex_fmt = "0.3.0"
regex = { version = "1.4.0", optional = true }
snap = {version = "1.0.3", optional = true }

[dev-dependencies]
async-std = "1.6.3"
Expand Down
Loading