Clarified stdout messages

master
Mike Goelzer 6 years ago
parent 2c232a606c
commit 869000fff4
No known key found for this signature in database
GPG Key ID: EDAC46A37751AD6D

@ -59,6 +59,7 @@ cd pubsub
This peer, which is not in bootstrapper mode, creates a node, subscribes to the shared topic string, spawns the same go routine, and then loops forever requesting user input and publishing each line to the topic. This peer, which is not in bootstrapper mode, creates a node, subscribes to the shared topic string, spawns the same go routine, and then loops forever requesting user input and publishing each line to the topic.
**Third terminal**: Create a JS peer to connect to bootstrap and publish on topic **Third terminal**: Create a JS peer to connect to bootstrap and publish on topic
``` ```
cd pubsub/js cd pubsub/js
npm install # first time only npm install # first time only

@ -8,7 +8,6 @@ import (
"os" "os"
_ "time" _ "time"
// ipfsaddr "github.com/ipfs/go-ipfs-addr"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
host "github.com/libp2p/go-libp2p-host" host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net" inet "github.com/libp2p/go-libp2p-net"
@ -45,7 +44,7 @@ func parseArgs() (bool, string) {
func handleConn(conn inet.Conn) { func handleConn(conn inet.Conn) {
ctx := context.Background() ctx := context.Background()
h := ho h := ho
fmt.Printf("<NOTICE> Got connection from %v\n", conn.RemoteMultiaddr().String()) fmt.Printf("<NOTICE> New peer joined: %v\n", conn.RemoteMultiaddr().String())
_ = h _ = h
_ = ctx _ = ctx
} }
@ -60,7 +59,7 @@ func main() {
} else { } else {
fmt.Printf("peer mode (port 6000)") fmt.Printf("peer mode (port 6000)")
} }
fmt.Printf(" with private key '%s'\n", privKeyFilePath) fmt.Printf("\nPrivate key '%s'\n", privKeyFilePath)
// //
// Read the private key and unmarshall it into struct // Read the private key and unmarshall it into struct
@ -166,12 +165,11 @@ func main() {
}, },
}) })
if bBootstrap { if bBootstrap {
fmt.Println("Bootstrapper running.\nDHT running.\nCtrl+C to exit and destroy DHT.") fmt.Println("Bootstrapper running.\nPubSub object instantiated using FloodSubRouter.\nCtrl+C to exit.")
for true { for true {
} }
} else { } else {
// Now, wait for input from the user, and send that out! // Now, wait for input from the user, and send that out!
fmt.Println("Type something and hit enter to send to other subscribers:")
scan := bufio.NewScanner(os.Stdin) scan := bufio.NewScanner(os.Stdin)
for scan.Scan() { for scan.Scan() {
if err := fsub.Publish(TopicName, scan.Bytes()); err != nil { if err := fsub.Publish(TopicName, scan.Bytes()); err != nil {

Loading…
Cancel
Save