peer

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: 12 Imported by: 0

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)

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 {
	Link *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) AttachChan

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

AttachChan set msg chan to sync link

func (*Peer) Close

func (this *Peer) Close()

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

func (this *Peer) GetPort() uint16

GetPort return peer`s sync port

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

func (this *Peer) GetSoftVersion() string

func (*Peer) GetState

func (this *Peer) GetState() uint32

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

Send transfer buffer by sync or cons link

func (*Peer) SendRaw

func (this *Peer) SendRaw(msgType string, msgPayload []byte) error

SendTo call sync link to send buffer

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

func (this *Peer) SetState(state uint32)

SetState set sync state to peer

func (*Peer) UpdateInfo

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

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

func (this *PeerCom) GetPort() uint16

GetPort returns a peer's sync port

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

func (this *PeerCom) GetSoftVersion() string

GetSoftVersion return a peer's software version

func (*PeerCom) GetVersion

func (this *PeerCom) GetVersion() uint32

GetVersion returns a peer's version

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

func (this *PeerCom) SetPort(port uint16)

SetPort sets a peer's sync port

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

func (this *PeerCom) SetSoftVersion(softVer string)

SetSoftVersion sets a peers's software version

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