Documentation ¶
Overview ¶
*
- Description:
- Author: Yihen.Liu
- Create: 2019-07-31
*
- Description:
- Author: Yihen.Liu
- Create: 2019-08-01
Index ¶
- Constants
- func AuthenticateMessage(message proto.Message, data *wire.MessageData) bool
- func NewMessageData(n *SeedNode, messageId string, gossip bool) *wire.MessageData
- func SendProtoMessage(data proto.Message, s core.Stream) bool
- func SignData(n *SeedNode, data []byte) ([]byte, error)
- func SignProtoMessage(n *SeedNode, message proto.Message) ([]byte, error)
- func VerifyData(data []byte, signature []byte, peerId peer.ID, pubKeyData []byte) bool
- type Seed
- type SeedListProtocol
- type SeedNode
Constants ¶
const ClientVersion = "go-p2p-node/0.0.1"
node client version
Variables ¶
This section is empty.
Functions ¶
func AuthenticateMessage ¶
func AuthenticateMessage(message proto.Message, data *wire.MessageData) bool
Authenticate incoming p2p message message: a protobufs go data object data: common p2p message data
func NewMessageData ¶
func NewMessageData(n *SeedNode, messageId string, gossip bool) *wire.MessageData
helper method - generate message data shared between all node's p2p protocols messageId: unique for requests, copied from request for responses
func SendProtoMessage ¶
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
func SignProtoMessage ¶
sign an outgoing p2p message payload
func VerifyData ¶
Verify incoming p2p message data integrity data: data to verify signature: author signature provided in the message payload peerId: author peer id from the message payload pubKeyData: author public key from the message payload
Types ¶
type SeedListProtocol ¶
type SeedListProtocol struct {
// contains filtered or unexported fields
}
func NewSeedListProtocol ¶
func NewSeedListProtocol(node *SeedNode, done chan struct{}) *SeedListProtocol
func (*SeedListProtocol) RequestSeedList ¶
func (seed *SeedListProtocol) RequestSeedList(pid peer.ID) bool
func (*SeedListProtocol) StartSeedlistGossipPubSub ¶
func (*SeedListProtocol) StartSeedlistGossipPubSub(ctx context.Context, host core.Host)
type SeedNode ¶
type SeedNode struct { core.Host // lib-p2p host *SeedListProtocol // seedlist protocol impl }
Node type - a p2p host implementing one or more p2p protocols
func NewSeedNode ¶
func NewSeedNode(host core.Host, done chan struct{}) *SeedNode
Create a new node with its implemented protocols