From 42bf62bcf695a9339ec99ad48592cd3e57d02245 Mon Sep 17 00:00:00 2001 From: rairyx Date: Wed, 10 Apr 2019 23:45:31 -0700 Subject: [PATCH] first commit --- pubsub/js/index.js | 5 +++-- pubsub/pubsub-interop.go | 7 ++++--- pubsub/rust/src/main.rs | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pubsub/js/index.js b/pubsub/js/index.js index 1ffc724..3868eb8 100644 --- a/pubsub/js/index.js +++ b/pubsub/js/index.js @@ -63,7 +63,8 @@ waterfall([ const peerIdStr = data.from const peerIdTruncdStr = peerIdStr.substr(0,2) + "*" + peerIdStr.substr(peerIdStr.length-6,6) const messageStr = data.data - console.log(": " + messageStr) + // console.log(": " + messageStr) + console.log(messageStr) }) fsub.subscribe(topicName) @@ -87,4 +88,4 @@ waterfall([ process.exit(0); }) -}) \ No newline at end of file +}) diff --git a/pubsub/pubsub-interop.go b/pubsub/pubsub-interop.go index 161c3cd..22e964d 100644 --- a/pubsub/pubsub-interop.go +++ b/pubsub/pubsub-interop.go @@ -15,7 +15,7 @@ import ( "github.com/libp2p/go-libp2p-crypto" - "github.com/libp2p/go-floodsub" + floodsub "github.com/libp2p/go-floodsub" ma "github.com/multiformats/go-multiaddr" ) @@ -101,7 +101,7 @@ func main() { // // Construct a floodsub instance for this host // - fsub, err := floodsub.NewFloodSub(ctx, host) + fsub, err := floodsub.NewFloodSub(ctx, host, floodsub.WithMessageSigning(false)) if err != nil { fmt.Println("Error (floodsub.NewFloodSub): %v", err) panic(err) @@ -152,7 +152,8 @@ func main() { panic(err) } - fmt.Printf("%s: %s\n", msg.GetFrom(), string(msg.GetData())) + //fmt.Printf("%s: %s\n", msg.GetFrom(), string(msg.GetData())) + fmt.Printf("%s\n", string(msg.GetData())) } }() diff --git a/pubsub/rust/src/main.rs b/pubsub/rust/src/main.rs index 5cf097b..4b4bdec 100644 --- a/pubsub/rust/src/main.rs +++ b/pubsub/rust/src/main.rs @@ -60,7 +60,8 @@ fn main() { fn on_floodsub(&mut self, message: as libp2p::core::swarm::NetworkBehaviour>::OutEvent) where TSubstream: libp2p::tokio_io::AsyncRead + libp2p::tokio_io::AsyncWrite { - println!("{:?}: {}", &message.source,String::from_utf8_lossy(&message.data)); + //println!("{:?}: {}", &message.source,String::from_utf8_lossy(&message.data)); + println!("Received: {}", String::from_utf8_lossy(&message.data)); } }