diff --git a/examples/multipro/main.go b/examples/multipro/main.go index 65e24477c6c5d1daca2ad9d491b80e96332c9bb7..b729c2048f28dd1754a87658bfd54e218ed08c28 100644 --- a/examples/multipro/main.go +++ b/examples/multipro/main.go @@ -16,7 +16,6 @@ import ( // helper method - create a lib-p2p host to listen on a port func makeRandomNode(port int, done chan bool) *Node { - // Ignoring most errors for brevity // See echo example for more details and better implementation priv, pub, _ := crypto.GenerateKeyPair(crypto.RSA, 2048) diff --git a/examples/multipro/node.go b/examples/multipro/node.go index 96bc7bf0f5e19a9225e13038b9be48588aed33fc..0f0d48ff8725c396c9159e9ceb1f9e1c6238bc91 100644 --- a/examples/multipro/node.go +++ b/examples/multipro/node.go @@ -33,7 +33,7 @@ func sendDataObject(data interface{}, s inet.Stream) bool { // helper method - generate message data shared between all node's p2p protocols // nodeId - message author id -// mesageId - unique for requests, copied from request for responses +// messageId - unique for requests, copied from request for responses func NewMessageData(nodeId string, messageId string, gossip bool) *p2p.MessageData { return &p2p.MessageData{ ClientVersion: clientVersion, diff --git a/examples/multipro/pb/p2p.proto b/examples/multipro/pb/p2p.proto index 38a0e49e3a57d4f154c2e8b7f7accc421bca1b68..62df22d29583104f3ab6c73d5e7e25bb090c4fdf 100644 --- a/examples/multipro/pb/p2p.proto +++ b/examples/multipro/pb/p2p.proto @@ -9,7 +9,7 @@ message MessageData { int64 timestamp = 2; // unix time string id = 3; // allows requesters to use request data when processing a response bool gossip = 4; // true to have receiver peer gossip the message to neighbors - string nodeId = 5; // id of node that created the message (not the one that may have relayed it) + string nodeId = 5; // id of node that created the message (not the peer that may have sent it) string sign = 6; // signature of message data + method specific data by message authoring node } diff --git a/examples/multipro/ping.go b/examples/multipro/ping.go index 0916f65dab13c9ccd83f1d055f35b745b09b0434..ca0020e9f6d2d1661bf797f554bae0d14f3cf288 100644 --- a/examples/multipro/ping.go +++ b/examples/multipro/ping.go @@ -48,10 +48,8 @@ func (p *PingProtocol) onPingRequest(s inet.Stream) { // send response to sender log.Printf("%s: Sending ping response to %s. Message id: %s...", s.Conn().LocalPeer(), s.Conn().RemotePeer(), data.MessageData.Id) - resp := &p2p.PingResponse{ - MessageData: NewMessageData(p.host.ID().String(), data.MessageData.Id, false), - Message: fmt.Sprintf("Ping response from %s", p.host.ID()), - } + resp := &p2p.PingResponse{MessageData: NewMessageData(p.host.ID().String(), data.MessageData.Id, false), + Message: fmt.Sprintf("Ping response from %s", p.host.ID())} s, respErr := p.host.NewStream(context.Background(), s.Conn().RemotePeer(), pingResponse) if respErr != nil { @@ -93,10 +91,8 @@ func (p *PingProtocol) Ping(node *Node) bool { log.Printf("%s: Sending ping to: %s....", p.host.ID(), node.host.ID()) // create message data - req := &p2p.PingRequest{ - MessageData: NewMessageData(p.host.ID().String(), uuid.New().String(), false), - Message: fmt.Sprintf("Ping from %s", p.host.ID()), - } + req := &p2p.PingRequest{MessageData: NewMessageData(p.host.ID().String(), uuid.New().String(), false), + Message: fmt.Sprintf("Ping from %s", p.host.ID())} s, err := p.host.NewStream(context.Background(), node.host.ID(), pingRequest) if err != nil {