first commit

This commit is contained in:
rairyx 2019-04-10 23:45:31 -07:00
parent dcad16fe67
commit 42bf62bcf6
3 changed files with 9 additions and 6 deletions

View File

@ -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("<peer " + peerIdTruncdStr + ">: " + messageStr)
// console.log("<peer " + peerIdTruncdStr + ">: " + messageStr)
console.log(messageStr)
})
fsub.subscribe(topicName)
@ -87,4 +88,4 @@ waterfall([
process.exit(0);
})
})
})

View File

@ -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()))
}
}()

View File

@ -60,7 +60,8 @@ fn main() {
fn on_floodsub<TTopology>(&mut self, message: <libp2p::floodsub::Floodsub<TSubstream> as libp2p::core::swarm::NetworkBehaviour<TTopology>>::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));
}
}