netserver

package
v0.0.0-...-f5d07b1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: LGPL-3.0 Imports: 18 Imported by: 0

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

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

InConnectionRecord include all addr connected

type NetServer

type NetServer struct {
	NetChan 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

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

func (this *NetServer) AddOutConnRecord(addr string)

AddOutConnRecord add out connection to outConnRecord

func (*NetServer) AddOutConnectingList

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

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

AddPeerAddress add sync addr to peer-addr map

func (*NetServer) AddrValid

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

func (this *NetServer) GetInConnRecordLen() int

GetInConnRecordLen return length of inConnRecordList

func (*NetServer) GetIpCountInInConnRecord

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

GetIpCountInInConnRecord return count of in connections with single ip

func (*NetServer) GetMsgChan

func (this *NetServer) GetMsgChan() 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

func (this *NetServer) GetOutConnRecordLen() int

GetOutConnRecordLen return length of outConnRecord

func (*NetServer) GetOutConnectingListLen

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

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

GetPeerAddressCount return length of cons addr from peer-addr map

func (*NetServer) GetPeerFromAddr

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

find exist peer from addr map

func (*NetServer) GetPort

func (this *NetServer) GetPort() uint16

GetPort return the sync port

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

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

check peer from connecting list

func (*NetServer) IsAddrInInConnRecord

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

IsAddrInInConnRecord return result whether addr is in inConnRecordList

func (*NetServer) IsAddrInOutConnRecord

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

IsAddrInOutConnRecord return result whether addr is in outConnRecord

func (*NetServer) IsIPInInConnRecord

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

IsNbrPeerAddr return result whether the address is under connecting

func (*NetServer) IsOwnAddress

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

func (this *NetServer) RemoveFromInConnRecord(addr string)

RemoveInConnRecord remove in connection from inConnRecordList

func (*NetServer) RemoveFromOutConnRecord

func (this *NetServer) RemoveFromOutConnRecord(addr string)

RemoveOutConnRecord remove out connection from outConnRecord

func (*NetServer) RemovePeerAddress

func (this *NetServer) RemovePeerAddress(addr string)

RemovePeerAddress remove sync addr from peer-addr map

func (*NetServer) Send

func (this *NetServer) Send(p *peer.Peer, msg types.Message) 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

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)

Xmit called by actor, broadcast msg

type OutConnectionRecord

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

OutConnectionRecord include all addr accepted

type PeerAddrMap

type PeerAddrMap struct {
	sync.RWMutex
	PeerAddress 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