netserver

package
v0.0.0-...-54ab005 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a net.Conn wrapper to do some clean up when Close.

func (*Conn) Close

func (self *Conn) Close() error

Close overwrite net.Conn

type NbrPeers

type NbrPeers struct {
	sync.RWMutex
	List map[common.PeerId]connectedPeer
	// contains filtered or unexported fields
}

NbrPeers: The neigbor list

func NewNbrPeers

func NewNbrPeers() *NbrPeers

func (*NbrPeers) Broadcast

func (this *NbrPeers) Broadcast(msg types.Message)

Broadcast tranfer msg buffer to all establish Peer

func (*NbrPeers) GetNbrNodeCnt

func (this *NbrPeers) GetNbrNodeCnt() uint32

GetNbrNodeCnt return count of establish peers in nbrlist

func (*NbrPeers) GetNeighborAddrs

func (this *NbrPeers) GetNeighborAddrs() []common.PeerAddr

GetNeighborAddrs return all establish Peer address

func (*NbrPeers) GetNeighborHeights

func (this *NbrPeers) GetNeighborHeights() map[common.PeerId]uint64

GetNeighborHeights return the id-height map of nbr peers

func (*NbrPeers) GetNeighborMostHeight

func (this *NbrPeers) GetNeighborMostHeight() uint64

GetNeighborMostHeight return the most height of nbr peers

func (*NbrPeers) GetNeighbors

func (this *NbrPeers) GetNeighbors() []*peer.Peer

GetNeighbors return all establish peers in nbr list

func (*NbrPeers) GetPeer

func (this *NbrPeers) GetPeer(id common.PeerId) *peer.Peer

GetPeer return Peer according to id

func (*NbrPeers) NodeExisted

func (this *NbrPeers) NodeExisted(uid common.PeerId) bool

NodeExisted return when Peer in nbr list

func (*NbrPeers) ReplacePeer

func (self *NbrPeers) ReplacePeer(p *peer.Peer, net *NetServer) *peer.Peer

type NetServer

type NetServer struct {
	NetChan chan *types.MsgPayload
	Np      *NbrPeers
	// contains filtered or unexported fields
}

NetServer represent all the actions in net layer

func NewCustomNetServer

func NewCustomNetServer(id *common.PeerKeyId, info *peer.PeerInfo, proto p2p.Protocol,
	listener net.Listener, opt connect_controller.ConnCtrlOption, logger common.Logger) *NetServer

func NewNetServer

func NewNetServer(protocol p2p.Protocol, conf *config.P2PNodeConfig, reserveAddrFilter p2p.AddressFilter) (*NetServer, error)

NewNetServer return the net object in p2p

func (*NetServer) Broadcast

func (this *NetServer) Broadcast(msg types.Message)

Broadcast called by actor, broadcast msg

func (*NetServer) Connect

func (this *NetServer) Connect(addr string)

Connect used to connect net address under sync or cons mode

func (*NetServer) ConnectController

func (ns *NetServer) ConnectController() *connect_controller.ConnectController

func (*NetServer) GetConnectionCnt

func (this *NetServer) GetConnectionCnt() uint32

GetConnectionCnt return the total number of valid connections

func (*NetServer) GetHeight

func (this *NetServer) GetHeight() uint64

GetHeight return peer's heigh

func (*NetServer) GetHostInfo

func (this *NetServer) GetHostInfo() *peer.PeerInfo

GetVersion return self peer`s version

func (*NetServer) GetID

func (this *NetServer) GetID() common.PeerId

GetId return peer`s id

func (*NetServer) GetMaxPeerBlockHeight

func (this *NetServer) GetMaxPeerBlockHeight() uint64

GetMaxPeerBlockHeight return the most height of valid connections

func (*NetServer) GetNeighborAddrs

func (this *NetServer) GetNeighborAddrs() []common.PeerAddr

GetNeighborAddrs return all the nbr peer`s addr

func (*NetServer) GetNeighbors

func (this *NetServer) GetNeighbors() []*peer.Peer

GetNeighbors return all nbr peer

func (*NetServer) GetOutConnRecordLen

func (this *NetServer) GetOutConnRecordLen() uint

GetOutConnRecordLen return length of outConnRecord

func (*NetServer) GetPeer

func (this *NetServer) GetPeer(id common.PeerId) *peer.Peer

GetPeer returns a peer with the peer id

func (*NetServer) GetSubnetMembersInfo

func (self *NetServer) GetSubnetMembersInfo() []common.SubnetMemberInfo

func (*NetServer) IsOwnAddress

func (this *NetServer) IsOwnAddress(addr string) bool

check own network address

func (*NetServer) Protocol

func (ns *NetServer) Protocol() p2p.Protocol

func (*NetServer) ReplacePeer

func (this *NetServer) ReplacePeer(remotePeer *peer.Peer)

func (*NetServer) Send

func (this *NetServer) Send(p *peer.Peer, msg types.Message) error

Tx sendMsg data buf to peer

func (*NetServer) SendTo

func (this *NetServer) SendTo(p common.PeerId, msg types.Message)

func (*NetServer) SetHeight

func (this *NetServer) SetHeight(height uint64)

SetHeight sets the local's height

func (*NetServer) Start

func (this *NetServer) Start() error

InitListen start listening on the config port

func (*NetServer) Stop

func (this *NetServer) Stop()

Stop stop all net layer logic

Jump to

Keyboard shortcuts

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