Commit 54aa54a5 authored by Aviv Eyal's avatar Aviv Eyal Committed by Steven Allen
Browse files

Updated comments

parent 01e1a19c
......@@ -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)
......
......@@ -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,
......
......@@ -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
}
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment