mirror of
https://github.com/rairyx/raven.git
synced 2024-11-11 19:10:50 +00:00
first commit
This commit is contained in:
parent
dcad16fe67
commit
42bf62bcf6
@ -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);
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
@ -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()))
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user