From f1da0f856e19d9d0db4599b30e156c085ea1a4ff Mon Sep 17 00:00:00 2001 From: venugopv Date: Mon, 6 Apr 2020 12:49:41 -0400 Subject: [PATCH] Update main.go Adding "ID" to create Node. Without Node having ID, it seems not possible to work with multiple nodes in the same machine. Faced problems in transferring data using TCP, with the above fix, the issue is gone. --- cmd/chat/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/chat/main.go b/cmd/chat/main.go index 5fc94cdf..037356e9 100644 --- a/cmd/chat/main.go +++ b/cmd/chat/main.go @@ -47,12 +47,19 @@ const printedLength = 8 func main() { // Parse flags/options. pflag.Parse() - + + //create a Node ID and use while creating Node, so that multiple nodes can be created in same machine. + pub, _, err := noise.GenerateKeys(nil) + check(err) + + id := noise.NewID(pub, *hostFlag, *portFlag) + // Create a new configured node. node, err := noise.NewNode( noise.WithNodeBindHost(*hostFlag), noise.WithNodeBindPort(*portFlag), noise.WithNodeAddress(*addressFlag), + noise.WithNodeID(id), ) check(err)