p2p

package
v2.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boot

type Boot interface {
	Start()
	Stop()
	All() []*BootLinkPeer
}

func NewBoot

func NewBoot(config config.Boot) Boot

type BootLinkPeer

type BootLinkPeer struct {
	Id   string
	Addr string
}

type HandShaker

type HandShaker interface {
	GetState() (interface{}, error)
	Handshake(peerId string, state []byte) error
	DecodeState(state []byte) interface{}
	EncodeState(state interface{}) []byte
}

type Msg

type Msg struct {
	T    common.NetMsgType // type: 2~100 basic msg  101~200:biz msg
	Data []byte
}

func NewMsg

func NewMsg(t common.NetMsgType, data []byte) *Msg

type MsgHandle

type MsgHandle func(common.NetMsgType, []byte, Peer)

type P2P

type P2P interface {
	BestPeer() (Peer, error)
	AllPeer() ([]Peer, error)
	SetHandlerFn(MsgHandle)
	SetHandShaker(HandShaker)
	Init()
	Start()
	Stop()
	Id() string
}

func NewP2P

func NewP2P(config *config.P2P) P2P

type P2PLifecycle

type P2PLifecycle struct {
	common.LifecycleStatus
}

0:origin 1: initing 2:inited 3:starting 4:started 5:stopping 6:stopped

type Peer

type Peer interface {
	Write(msg *Msg) error
	Id() string
	RemoteAddr() string
	SetState(interface{})
	GetState() interface{}
}

Jump to

Keyboard shortcuts

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