Skip to content

Commit

Permalink
Gossipsub 1.1 ammendments (#50)
Browse files Browse the repository at this point in the history
* Shuffling things around

* Further minor ammendments

* Misc typos and improvements

* Correct tests

* Wasm support
  • Loading branch information
AgeManning authored Aug 24, 2020
1 parent 5d93c0a commit 3206da5
Show file tree
Hide file tree
Showing 14 changed files with 532 additions and 318 deletions.
10 changes: 6 additions & 4 deletions examples/gossipsub-chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ fn main() -> Result<(), Box<dyn Error>> {
.heartbeat_interval(Duration::from_secs(10))
.message_id_fn(message_id_fn) // content-address messages. No two messages of the
//same content will be propagated.
.build().expect("Valid config");
.build()
.expect("Valid config");
// build a gossipsub network behaviour
let mut gossipsub =
gossipsub::Gossipsub::new(MessageAuthenticity::Signed(local_key), gossipsub_config);
gossipsub::Gossipsub::new(MessageAuthenticity::Signed(local_key), gossipsub_config)
.expect("Correct configuration");
gossipsub.subscribe(topic.clone());
if let Some(explicit) = std::env::args().nth(2) {
let explicit = explicit.clone();
Expand Down Expand Up @@ -142,10 +144,10 @@ fn main() -> Result<(), Box<dyn Error>> {
loop {
match swarm.poll_next_unpin(cx) {
Poll::Ready(Some(gossip_event)) => match gossip_event {
GossipsubEvent::Message{
GossipsubEvent::Message {
propagation_source: peer_id,
message_id: id,
message
message,
} => println!(
"Got message: {} with id: {} from peer: {:?}",
String::from_utf8_lossy(&message.data),
Expand Down
8 changes: 5 additions & 3 deletions examples/ipfs-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn main() -> Result<(), Box<dyn Error>> {
GossipsubEvent::Message {
propagation_source: peer_id,
message_id: id,
message
message,
} => println!(
"Got message: {} with id: {} from peer: {:?}",
String::from_utf8_lossy(&message.data),
Expand Down Expand Up @@ -245,12 +245,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut swarm = {
let gossipsub_config = GossipsubConfigBuilder::new()
.max_transmit_size(262144)
.build().expect("valid config");
.build()
.expect("valid config");
let mut behaviour = MyBehaviour {
gossipsub: Gossipsub::new(
MessageAuthenticity::Signed(local_key.clone()),
gossipsub_config,
),
)
.expect("Valid configuration"),
identify: Identify::new(
"/ipfs/0.1.0".into(),
"rust-ipfs-example".into(),
Expand Down
Loading

0 comments on commit 3206da5

Please sign in to comment.