Browse Source

Added authors

pull/280/head
Aviv Eyal 7 years ago
committed by Steven Allen
parent
commit
2dbb78f88f
  1. 3
      examples/multipro/AUTHORS
  2. 5
      examples/multipro/node.go
  3. 4
      examples/multipro/pb/p2p.proto
  4. 7
      examples/multipro/protocol.go

3
examples/multipro/AUTHORS

@ -0,0 +1,3 @@
# This is the official list of authors for copyright purposes.
Aviv Eyal <aviveyal07@gmail.com>

5
examples/multipro/node.go

@ -10,6 +10,9 @@ import (
"time" "time"
) )
// node client version
const clientVersion = "go-p2p-node/0.0.1"
// Node type - a p2p host implementing one or more p2p protocols // Node type - a p2p host implementing one or more p2p protocols
type Node struct { type Node struct {
host.Host // lib-p2p host host.Host // lib-p2p host
@ -93,7 +96,7 @@ func (n *Node) verifyData(data []byte, signature []byte, peerId peer.ID, pubKeyD
return false return false
} }
// verify that message author node id matches the provided public key // verify that message author node id matches the provided node public key
if idFromKey != peerId { if idFromKey != peerId {
log.Println(err, "Node id and provided public key mismatch") log.Println(err, "Node id and provided public key mismatch")
return false return false

4
examples/multipro/pb/p2p.proto

@ -10,8 +10,8 @@ message MessageData {
string id = 3; // allows requesters to use request data when processing a response 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 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 peer that may have sent it). =base58(mh(sha256(nodePubKey))) string nodeId = 5; // id of node that created the message (not the peer that may have sent it). =base58(mh(sha256(nodePubKey)))
bytes nodePubKey = 6; // Authoring node Secp256k1 public key (32bytes) bytes nodePubKey = 6; // Authoring node Secp256k1 public key (32bytes) - protobufs serielized
string sign = 7; // signature of message data + method specific data by message authoring node string sign = 7; // signature of message data + method specific data by message authoring node. format: string([]bytes)
} }
//// ping protocol //// ping protocol

7
examples/multipro/protocol.go

@ -8,12 +8,9 @@ import (
"log" "log"
) )
// node version
const clientVersion = "go-p2p-node/0.0.1"
// helper method - writes a protobuf go data object to a network stream // helper method - writes a protobuf go data object to a network stream
// data - reference of protobuf go data object to send (not the object itself) // data: reference of protobuf go data object to send (not the object itself)
// s - network stream to write the data to // s: network stream to write the data to
func sendProtoMessage(data proto.Message, s inet.Stream) bool { func sendProtoMessage(data proto.Message, s inet.Stream) bool {
writer := bufio.NewWriter(s) writer := bufio.NewWriter(s)
enc := protobufCodec.Multicodec(nil).Encoder(writer) enc := protobufCodec.Multicodec(nil).Encoder(writer)

Loading…
Cancel
Save