protocols

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTooLong = iota
	ErrDecode
	ErrWrite
	ErrInvalidMsgCode
	ErrInvalidMsgType
	ErrHandshake
	ErrNoHandler
	ErrHandler
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code int
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() (message string)

type Peer

type Peer struct {
	*p2p.Peer
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer

func (*Peer) Drop

func (p *Peer) Drop(err error)

func (*Peer) Handshake

func (p *Peer) Handshake(ctx context.Context, hs interface{}, verify func(interface{}) error) (rhs interface{}, err error)

func (*Peer) Run

func (p *Peer) Run(handler func(msg interface{}) error) error

func (*Peer) Send

func (p *Peer) Send(msg interface{}) error

type Spec

type Spec struct {
	Name string

	Version uint

	MaxMsgSize uint32

	Messages []interface{}
	// contains filtered or unexported fields
}

func (*Spec) GetCode

func (s *Spec) GetCode(msg interface{}) (uint64, bool)

func (*Spec) Length

func (s *Spec) Length() uint64

func (*Spec) NewMsg

func (s *Spec) NewMsg(code uint64) (interface{}, bool)

Jump to

Keyboard shortcuts

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