wired

package
Version: v0.0.0-...-8d08d5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeChainPayload

func DecodeChainPayload(rawPayload []byte) (*message.ChainPayload, error)

DecodeChainPayload unmarshal the raw and return the *pb.ChainPayload.

func DecodePongPayload

func DecodePongPayload(rawPayload []byte) (*message.PongPayload, error)

DecodePongPayload unmarshal the raw and return the *pb.PongPayload.

func NewHeader

func NewHeader(host core.Host, network ngtypes.NetworkType, msgID []byte, msgType message.MessageType) *message.Header

NewHeader is a helper method: generate message data shared between all node's p2p protocols

func ReceiveReply

func ReceiveReply(uuid []byte, stream network.Stream) (*message.Message, error)

ReceiveReply will receive the correct reply message from the stream

func Reply

func Reply(stream network.Stream, data proto.Message) error

func Send

func Send(host core.Host, protocolID protocol.ID, peerID peer.ID, data proto.Message) (network.Stream, error)

Send is a helper method - writes a protobuf go data object to a network stream. then the stream will be returned and caller is able to read the response from it.

func Signature

func Signature(host core.Host, message *message.Message) ([]byte, error)

Signature an outgoing p2p message payload.

func Verify

func Verify(peerID peer.ID, message *message.Message) bool

Verify verifies the data and sign in message

Types

type Wired

type Wired struct {
	// contains filtered or unexported fields
}

Wired type

func NewWiredProtocol

func NewWiredProtocol(host core.Host, network ngtypes.NetworkType, chain *ngchain.Chain) *Wired

func (*Wired) GetWiredProtocol

func (w *Wired) GetWiredProtocol() protocol.ID

func (*Wired) GoServe

func (w *Wired) GoServe()

func (*Wired) SendGetChain

func (w *Wired) SendGetChain(peerID peer.ID, from [][]byte, to []byte) (id []byte, stream network.Stream, err error)

func (*Wired) SendPing

func (w *Wired) SendPing(peerID peer.ID, origin, latest uint64, checkpointHash, checkpointActualDiff []byte) (id []byte,
	stream network.Stream)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL