netserver

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: LGPL-3.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNetServer

func NewNetServer() p2p.P2P

NewNetServer return the net object in p2p

func TLSDial

func TLSDial(nodeAddr string) (net.Conn, error)

TLSDial return net.Conn with TLS

Types

type ConnectingNodes

type ConnectingNodes struct {
	sync.RWMutex
	ConnectingAddrs []string
}

ConnectingNodes include all addr in connecting state

type InConnectionRecord added in v0.9.2

type InConnectionRecord struct {
	sync.RWMutex
	InConnectingAddrs []string
}

InConnectionRecord include all addr connected

type NetServer

type NetServer struct {
	SyncChan chan *types.MsgPayload
	ConsChan chan *types.MsgPayload
	ConnectingNodes
	PeerAddrMap
	Np *peer.NbrPeers

	OwnAddress string //network`s own address(ip : sync port),which get from version check
	// contains filtered or unexported fields
}

NetServer represent all the actions in net layer

func (*NetServer) AddInConnRecord added in v0.9.2

func (this *NetServer) AddInConnRecord(addr string)

AddInConnRecord add in connection to inConnRecord

func (*NetServer) AddNbrNode

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

AddNbrNode add peer to nbr peer list

func (*NetServer) AddOutConnRecord added in v0.9.2

func (this *NetServer) AddOutConnRecord(addr string)

AddOutConnRecord add out connection to outConnRecord

func (*NetServer) AddOutConnectingList added in v0.9.2

func (this *NetServer) AddOutConnectingList(addr string) (added bool)

record the peer which is going to be dialed and sent version message but not in establish state

func (*NetServer) AddPeerConsAddress

func (this *NetServer) AddPeerConsAddress(addr string, p *peer.Peer)

AddPeerConsAddress add cons addr to peer-addr map

func (*NetServer) AddPeerSyncAddress

func (this *NetServer) AddPeerSyncAddress(addr string, p *peer.Peer)

AddPeerSyncAddress add sync addr to peer-addr map

func (*NetServer) AddrValid added in v0.9.2

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

AddrValid whether the addr could be connect or accept

func (*NetServer) Connect

func (this *NetServer) Connect(addr string, isConsensus bool) error

Connect used to connect net address under sync or cons mode

func (*NetServer) DelNbrNode

func (this *NetServer) DelNbrNode(id uint64) (*peer.Peer, bool)

DelNbrNode delete nbr peer by id

func (*NetServer) GetConnectionCnt

func (this *NetServer) GetConnectionCnt() uint32

GetConnectionCnt return the total number of valid connections

func (*NetServer) GetConsPort

func (this *NetServer) GetConsPort() uint16

GetConsPort return the cons port

func (*NetServer) GetHeight

func (this *NetServer) GetHeight() uint64

GetHeight return peer's heigh

func (*NetServer) GetHttpInfoPort

func (this *NetServer) GetHttpInfoPort() uint16

GetHttpInfoPort return the port support info via http

func (*NetServer) GetID

func (this *NetServer) GetID() uint64

GetId return peer`s id

func (*NetServer) GetInConnRecordLen added in v0.9.2

func (this *NetServer) GetInConnRecordLen() int

GetInConnRecordLen return length of inConnRecordList

func (*NetServer) GetIpCountInInConnRecord added in v0.9.2

func (this *NetServer) GetIpCountInInConnRecord(ip string) uint

GetIpCountInInConnRecord return count of in connections with single ip

func (*NetServer) GetMsgChan

func (this *NetServer) GetMsgChan(isConsensus bool) chan *types.MsgPayload

GetMsgChan return sync or consensus channel when msgrouter need msg input

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) GetNp

func (this *NetServer) GetNp() *peer.NbrPeers

return nbr peers collection

func (*NetServer) GetOutConnRecordLen added in v0.9.2

func (this *NetServer) GetOutConnRecordLen() int

GetOutConnRecordLen return length of outConnRecord

func (*NetServer) GetOutConnectingListLen added in v0.9.2

func (this *NetServer) GetOutConnectingListLen() (count uint)

record the peer which is going to be dialed and sent version message but not in establish state

func (*NetServer) GetPeer

func (this *NetServer) GetPeer(id uint64) *peer.Peer

GetPeer returns a peer with the peer id

func (*NetServer) GetPeerFromAddr

func (this *NetServer) GetPeerFromAddr(addr string) *peer.Peer

find exist peer from addr map

func (*NetServer) GetPeerSyncAddressCount added in v0.9.2

func (this *NetServer) GetPeerSyncAddressCount() (count uint)

GetPeerSyncAddressCount return length of cons addr from peer-addr map

func (*NetServer) GetRelay

func (this *NetServer) GetRelay() bool

GetRelay return whether net module can relay msg

func (*NetServer) GetServices

func (this *NetServer) GetServices() uint64

GetServices return the service state of self peer

func (*NetServer) GetSyncPort

func (this *NetServer) GetSyncPort() uint16

GetSyncPort return the sync port

func (*NetServer) GetTime

func (this *NetServer) GetTime() int64

GetTime return the last contact time of self peer

func (*NetServer) GetVersion

func (this *NetServer) GetVersion() uint32

GetVersion return self peer`s version

func (*NetServer) Halt

func (this *NetServer) Halt()

Halt stop all net layer logic

func (*NetServer) IsAddrFromConnecting added in v0.9.4

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

check peer from connecting list

func (*NetServer) IsAddrInInConnRecord added in v0.9.2

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

IsAddrInInConnRecord return result whether addr is in inConnRecordList

func (*NetServer) IsAddrInOutConnRecord added in v0.9.2

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

IsAddrInOutConnRecord return result whether addr is in outConnRecord

func (*NetServer) IsIPInInConnRecord added in v0.9.2

func (this *NetServer) IsIPInInConnRecord(ip string) bool

IsIPInInConnRecord return result whether the IP is in inConnRecordList

func (*NetServer) IsNbrPeerAddr

func (this *NetServer) IsNbrPeerAddr(addr string, isConsensus bool) bool

IsNbrPeerAddr return result whether the address is under connecting

func (*NetServer) IsOwnAddress added in v0.9.3

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

check own network address

func (*NetServer) IsPeerEstablished

func (this *NetServer) IsPeerEstablished(p *peer.Peer) bool

IsPeerEstablished return the establise state of given peer`s id

func (*NetServer) NodeEstablished

func (this *NetServer) NodeEstablished(id uint64) bool

NodeEstablished return whether a peer is establish with self according to id

func (*NetServer) RemoveFromConnectingList

func (this *NetServer) RemoveFromConnectingList(addr string)

Remove the peer from connecting list if the connection is established

func (*NetServer) RemoveFromInConnRecord added in v0.9.2

func (this *NetServer) RemoveFromInConnRecord(addr string)

RemoveInConnRecord remove in connection from inConnRecordList

func (*NetServer) RemoveFromOutConnRecord added in v0.9.2

func (this *NetServer) RemoveFromOutConnRecord(addr string)

RemoveOutConnRecord remove out connection from outConnRecord

func (*NetServer) RemovePeerConsAddress

func (this *NetServer) RemovePeerConsAddress(addr string)

RemovePeerConsAddress remove cons addr from peer-addr map

func (*NetServer) RemovePeerSyncAddress

func (this *NetServer) RemovePeerSyncAddress(addr string)

RemovePeerSyncAddress remove sync addr from peer-addr map

func (*NetServer) Send

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

Tx send data buf to peer

func (*NetServer) SetHeight

func (this *NetServer) SetHeight(height uint64)

SetHeight sets the local's height

func (*NetServer) SetOwnAddress added in v0.9.3

func (this *NetServer) SetOwnAddress(addr string)

Set own network address

func (*NetServer) Start

func (this *NetServer) Start()

InitListen start listening on the config port

func (*NetServer) Xmit

func (this *NetServer) Xmit(msg types.Message, isCons bool)

Xmit called by actor, broadcast msg

type OutConnectionRecord added in v0.9.2

type OutConnectionRecord struct {
	sync.RWMutex
	OutConnectingAddrs []string
}

OutConnectionRecord include all addr accepted

type PeerAddrMap

type PeerAddrMap struct {
	sync.RWMutex
	PeerSyncAddress map[string]*peer.Peer
	PeerConsAddress map[string]*peer.Peer
}

PeerAddrMap include all addr-peer list

Jump to

Keyboard shortcuts

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