peer

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: LGPL-3.0 Imports: 11 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NbrPeers

type NbrPeers struct {
	sync.RWMutex
	List map[uint64]*Peer
}

NbrPeers: The neigbor list

func (*NbrPeers) AddNbrNode

func (this *NbrPeers) AddNbrNode(p *Peer)

AddNbrNode add peer to nbr list

func (*NbrPeers) Broadcast

func (this *NbrPeers) Broadcast(msg types.Message, isConsensus bool)

Broadcast tranfer msg buffer to all establish peer

func (*NbrPeers) DelNbrNode

func (this *NbrPeers) DelNbrNode(id uint64) (*Peer, bool)

DelNbrNode delete peer from nbr list

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[uint64]uint64

GetNeighborHeights return the id-height map of nbr peers

func (*NbrPeers) GetNeighbors

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

GetNeighbors return all establish peers in nbr list

func (*NbrPeers) GetPeer

func (this *NbrPeers) GetPeer(id uint64) *Peer

GetPeer return peer according to id

func (*NbrPeers) Init

func (this *NbrPeers) Init()

initialize nbr list

func (*NbrPeers) NodeEstablished

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

NodeEstablished whether peer established according to id

func (*NbrPeers) NodeExisted

func (this *NbrPeers) NodeExisted(uid uint64) bool

NodeExisted return when peer in nbr list

type Peer

type Peer struct {
	SyncLink *conn.Link
	ConsLink *conn.Link
	// contains filtered or unexported fields
}

Peer represent the node in p2p

func NewPeer

func NewPeer() *Peer

NewPeer return new peer without publickey initial

func (*Peer) AttachConsChan

func (this *Peer) AttachConsChan(msgchan chan *types.MsgPayload)

AttachConsChan set msg chan to consensus link

func (*Peer) AttachSyncChan

func (this *Peer) AttachSyncChan(msgchan chan *types.MsgPayload)

AttachSyncChan set msg chan to sync link

func (*Peer) CloseCons

func (this *Peer) CloseCons()

CloseCons halt consensus connection

func (*Peer) CloseSync

func (this *Peer) CloseSync()

CloseSync halt sync connection

func (*Peer) DumpInfo

func (this *Peer) DumpInfo()

DumpInfo print all information of peer

func (*Peer) GetAddr

func (this *Peer) GetAddr() string

GetAddr return peer`s sync link address

func (*Peer) GetAddr16

func (this *Peer) GetAddr16() ([16]byte, error)

GetAddr16 return peer`s sync link address in []byte

func (*Peer) GetConsConn

func (this *Peer) GetConsConn() *conn.Link

GetConsConn return consensus link

func (*Peer) GetConsPort

func (this *Peer) GetConsPort() uint16

GetConsPort return peer`s consensus port

func (*Peer) GetConsState

func (this *Peer) GetConsState() uint32

GetConsState return peer`s consensus state

func (*Peer) GetContactTime

func (this *Peer) GetContactTime() time.Time

GetContactTime return peer`s latest contact time in Time struct

func (*Peer) GetHeight

func (this *Peer) GetHeight() uint64

GetHeight return peer`s block height

func (*Peer) GetHttpInfoPort

func (this *Peer) GetHttpInfoPort() uint16

GetHttpInfoPort return peer`s httpinfo port

func (*Peer) GetHttpInfoState

func (this *Peer) GetHttpInfoState() bool

GetHttpInfoState return peer`s httpinfo state

func (*Peer) GetID

func (this *Peer) GetID() uint64

GetID return peer`s id

func (*Peer) GetRelay

func (this *Peer) GetRelay() bool

GetRelay return peer`s relay state

func (*Peer) GetServices

func (this *Peer) GetServices() uint64

GetServices return peer`s service state

func (*Peer) GetSyncPort

func (this *Peer) GetSyncPort() uint16

GetSyncPort return peer`s sync port

func (*Peer) GetSyncState

func (this *Peer) GetSyncState() uint32

GetSyncState return sync state

func (*Peer) GetTimeStamp

func (this *Peer) GetTimeStamp() int64

GetTimeStamp return peer`s latest contact time in ticks

func (*Peer) GetVersion

func (this *Peer) GetVersion() uint32

GetVersion return peer`s version

func (*Peer) Send

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

Send transfer buffer by sync or cons link

func (*Peer) SendToCons

func (this *Peer) SendToCons(msg types.Message) error

SendToCons call consensus link to send buffer

func (*Peer) SendToSync

func (this *Peer) SendToSync(msg types.Message) error

SendToSync call sync link to send buffer

func (*Peer) SetConsConn

func (this *Peer) SetConsConn(consLink *conn.Link)

SetConsConn set consensue link to peer

func (*Peer) SetConsPort

func (this *Peer) SetConsPort(port uint16)

SetConsPort set peer`s consensus port

func (*Peer) SetConsState

func (this *Peer) SetConsState(state uint32)

SetConsState set consensus state to peer

func (*Peer) SetHeight

func (this *Peer) SetHeight(height uint64)

SetHeight set height to peer

func (*Peer) SetHttpInfoPort

func (this *Peer) SetHttpInfoPort(port uint16)

SetHttpInfoPort set peer`s httpinfo port

func (*Peer) SetHttpInfoState

func (this *Peer) SetHttpInfoState(httpInfo bool)

SetHttpInfoState set peer`s httpinfo state

func (*Peer) SetSyncState

func (this *Peer) SetSyncState(state uint32)

SetSyncState set sync state to peer

func (*Peer) UpdateInfo

func (this *Peer) UpdateInfo(t time.Time, version uint32, services uint64,
	syncPort uint16, consPort uint16, nonce uint64, relay uint8, height uint64)

UpdateInfo update peer`s information

type PeerCom

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

PeerCom provides the basic information of a peer

func (*PeerCom) GetConsPort

func (this *PeerCom) GetConsPort() uint16

GetConsPort returns a peer's consensus port

func (*PeerCom) GetHeight

func (this *PeerCom) GetHeight() uint64

GetHeight returns a peer's height

func (*PeerCom) GetHttpInfoPort

func (this *PeerCom) GetHttpInfoPort() uint16

GetHttpInfoPort returns a peer's http info port

func (*PeerCom) GetID

func (this *PeerCom) GetID() uint64

GetID returns a peer's id

func (*PeerCom) GetRelay

func (this *PeerCom) GetRelay() bool

GetRelay returns a peer's relay

func (*PeerCom) GetServices

func (this *PeerCom) GetServices() uint64

GetServices returns a peer's services

func (*PeerCom) GetSyncPort

func (this *PeerCom) GetSyncPort() uint16

GetSyncPort returns a peer's sync port

func (*PeerCom) GetVersion

func (this *PeerCom) GetVersion() uint32

GetVersion returns a peer's version

func (*PeerCom) SetConsPort

func (this *PeerCom) SetConsPort(port uint16)

SetConsPort sets a peer's consensus port

func (*PeerCom) SetHeight

func (this *PeerCom) SetHeight(height uint64)

SetHeight sets a peer's height

func (*PeerCom) SetHttpInfoPort

func (this *PeerCom) SetHttpInfoPort(port uint16)

SetHttpInfoPort sets a peer's http info port

func (*PeerCom) SetID

func (this *PeerCom) SetID(id uint64)

SetID sets a peer's id

func (*PeerCom) SetRelay

func (this *PeerCom) SetRelay(relay bool)

SerRelay sets a peer's relay

func (*PeerCom) SetServices

func (this *PeerCom) SetServices(services uint64)

SetServices sets a peer's services

func (*PeerCom) SetSyncPort

func (this *PeerCom) SetSyncPort(port uint16)

SetSyncPort sets a peer's sync port

func (*PeerCom) SetVersion

func (this *PeerCom) SetVersion(version uint32)

SetVersion sets a peer's version

Jump to

Keyboard shortcuts

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