Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
2dbb78f8
Commit
2dbb78f8
authored
Nov 29, 2017
by
Aviv Eyal
Committed by
Steven Allen
Feb 21, 2018
Browse files
Added authors
parent
9f756444
Changes
4
Show whitespace changes
Inline
Side-by-side
examples/multipro/AUTHORS
0 → 100644
View file @
2dbb78f8
# This is the official list of authors for copyright purposes.
Aviv Eyal <aviveyal07@gmail.com>
\ No newline at end of file
examples/multipro/node.go
View file @
2dbb78f8
...
...
@@ -10,6 +10,9 @@ import (
"time"
)
// node client version
const
clientVersion
=
"go-p2p-node/0.0.1"
// Node type - a p2p host implementing one or more p2p protocols
type
Node
struct
{
host
.
Host
// lib-p2p host
...
...
@@ -93,7 +96,7 @@ func (n *Node) verifyData(data []byte, signature []byte, peerId peer.ID, pubKeyD
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
{
log
.
Println
(
err
,
"Node id and provided public key mismatch"
)
return
false
...
...
examples/multipro/pb/p2p.proto
View file @
2dbb78f8
...
...
@@ -10,8 +10,8 @@ message MessageData {
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 peer that may have sent it). =base58(mh(sha256(nodePubKey)))
bytes
nodePubKey
=
6
;
// Authoring node Secp256k1 public key (32bytes)
string
sign
=
7
;
// signature of message data + method specific data by message authoring node
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
. format: string([]bytes)
}
//// ping protocol
...
...
examples/multipro/protocol.go
View file @
2dbb78f8
...
...
@@ -8,12 +8,9 @@ import (
"log"
)
// node version
const
clientVersion
=
"go-p2p-node/0.0.1"
// 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)
// s
-
network stream to write the data to
// data
:
reference of protobuf go data object to send (not the object itself)
// s
:
network stream to write the data to
func
sendProtoMessage
(
data
proto
.
Message
,
s
inet
.
Stream
)
bool
{
writer
:=
bufio
.
NewWriter
(
s
)
enc
:=
protobufCodec
.
Multicodec
(
nil
)
.
Encoder
(
writer
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment