discover

package
v3.8.0+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	//TIME_PEER_INFO_EXCHANGE get peer info timer,  second
	TIMER_PEER_EXCHANGE = 5
	MAX_REQ_COUNT       = 10
)

DO NOT EDIT

View Source
const (
	//TIME_DISCOVER connect to unknow peer, second
	TIME_DISCOVER = 5
	//NEIGHBOR_DISCOVER_COUNT
	NEIGHBOR_DISCOVER_COUNT = 10
)

DO NOT EDIT

View Source
const (
	//TIME_KEEP_LIVE ping/pong timer, second
	TIMER_KEEP_LIVE = 10
	//TIMER_CHECK time out second
	TIMER_CHECK = 40
)

DO NOT EDIT

View Source
const (
	TIME_FAST_PNE_EXCHANGE = 8
	//TIME_PNE_EXCHANGE time to exchange peer neighbor info, minute
	TIME_PNE_EXCHANGE = 30
)

DO NOT EDIT

View Source
const (
	PEER_INFO_REQ = 1
	PEER_INFO_RSP = 2

	PEER_HANDSHAKE_REQ     = 3
	PEER_HANDSHAKE_RSP     = 4
	PEER_HANDSHAKE_RSP_ACK = 5

	PEER_NEIGHBOR_REQ = 7
	PEER_NEIGHBOR_RSP = 8

	PEER_PING = 9
	PEER_PONG = 10
)

DO NOT EDIT

View Source
const (
	MAX_PEER_COUNT = 100
)

DO NOT EDIT

Variables

This section is empty.

Functions

func Sha256

func Sha256(msg []byte) []byte

Sha256 sha256

Types

type Discover

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

Discover p2p protocol

func MakeDiscover

func MakeDiscover(config *config.P2PConfig) *Discover

MakeDiscover create instance

func (*Discover) Dispatch

func (d *Discover) Dispatch(index uint16, p *p2p.Packet)

Dispatch process peer message

func (*Discover) NewConnCb

func (d *Discover) NewConnCb(conn net.Conn, sendup p2p.SendupCb)

NewConnCb accept a connection with a peer

func (*Discover) SetSendupCallback

func (d *Discover) SetSendupCallback(cb p2p.SendupCb)

SetSendupCallback set sendup callback

func (*Discover) Start

func (d *Discover) Start()

Start start...

type PeerInfoReq

type PeerInfoReq struct {
}

PeerInfoReq peer info

type PeerInfoRsp

type PeerInfoRsp struct {
	Info p2p.PeerInfo
}

PeerInfoRsp peer info response

type PeerNeighborReq

type PeerNeighborReq struct {
}

PeerNeighborReq pne exchange request

type PeerNeighborRsp

type PeerNeighborRsp struct {
	Neighbor []p2p.PeerInfo
}

PeerNeighborRsp pne exchange response

Jump to

Keyboard shortcuts

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