peer

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FetchOutOfRangeState added in v1.0.2

type FetchOutOfRangeState struct {
	KeyPointIDList [][]byte
	sync.Mutex
}

type NbrPeers

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

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(mesg types.Message, isConsensus bool, magic uint32)

Broadcast tranfer msg buffer to all establish peer

func (*NbrPeers) DelNbrNode

func (this *NbrPeers) DelNbrNode(p *Peer) (*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() []*types.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

	TrxCache trxCache

	OutOfRangeState FetchOutOfRangeState

	ConsensusCache *common.HashCache
	// contains filtered or unexported fields
}

Peer represent the node in p2p

func NewPeer

func NewPeer(lg *logrus.Logger) *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(log *logrus.Logger)

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

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

func (this *Peer) GetID() uint64

GetID return peer`s id

func (*Peer) GetLastSeenBlkNum added in v1.0.2

func (this *Peer) GetLastSeenBlkNum() uint64

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

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) HasConsensusMsg added in v1.0.2

func (this *Peer) HasConsensusMsg(hash [common.HashSize]byte) bool

func (*Peer) HasTrx added in v1.0.2

func (this *Peer) HasTrx(hash []byte) bool

func (*Peer) IPv4 added in v1.0.2

func (this *Peer) IPv4() string

func (*Peer) LockBusy added in v1.0.2

func (this *Peer) LockBusy() bool

func (*Peer) LockBusyFetchingCP added in v1.0.2

func (this *Peer) LockBusyFetchingCP() bool

func (*Peer) Port added in v1.0.2

func (this *Peer) Port() uint16

func (*Peer) RecordConsensusMsg added in v1.0.2

func (this *Peer) RecordConsensusMsg(hash [common.HashSize]byte)

func (*Peer) RecordTrxCache added in v1.0.2

func (this *Peer) RecordTrxCache(hash []byte)

func (*Peer) Send

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

Send transfer buffer by sync or cons link

func (*Peer) SendToCons

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

SendToCons call consensus link to send buffer

func (*Peer) SendToSync

func (this *Peer) SendToSync(msg types.Message, magic uint32) 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 uint32)

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) SetLastSeenBlkNum added in v1.0.2

func (this *Peer) SetLastSeenBlkNum(num uint64)

func (*Peer) SetSyncState

func (this *Peer) SetSyncState(state uint32)

SetSyncState set sync state to peer

func (*Peer) UnlockBusy added in v1.0.2

func (this *Peer) UnlockBusy()

func (*Peer) UnlockBusyFetchingCP added in v1.0.2

func (this *Peer) UnlockBusyFetchingCP()

func (*Peer) UpdateInfo

func (this *Peer) UpdateInfo(t time.Time, version uint32, services uint64,
	syncPort uint32, consPort uint32, nonce uint64, relay uint32, height uint64, runningVersion 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) GetConsPort

func (this *PeerCom) GetConsPort() uint32

GetConsPort returns a peer's consensus port

func (*PeerCom) GetHeight

func (this *PeerCom) GetHeight() uint64

GetHeight returns a peer's height

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

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

SetConsPort sets a peer's consensus port

func (*PeerCom) SetHeight

func (this *PeerCom) SetHeight(height uint64)

SetHeight sets a peer's height

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

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