peer

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: LGPL-3.0 Imports: 12 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	Info *PeerInfo
	Link *conn.Link
	// contains filtered or unexported fields
}

Peer represent the node in p2p

func NewPeer

func NewPeer(info *PeerInfo, c net.Conn, msgChan chan *types.MsgPayload) *Peer

NewPeer return new peer without publickey initial

func (*Peer) Close added in v1.6.2

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

func (this *Peer) GetID() common.PeerId

GetID return peer`s id

func (*Peer) GetPort added in v1.6.2

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 added in v1.6.0

func (this *Peer) GetSoftVersion() string

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 added in v1.6.0

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

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

UpdateInfo update peer`s information

type PeerInfo added in v1.10.0

type PeerInfo struct {
	Id           common.PeerId
	Version      uint32
	Services     uint64
	Relay        bool
	HttpInfoPort uint16
	Port         uint16
	Height       uint64
	SoftVersion  string
	Addr         string
}

PeerInfo provides the basic information of a peer

func NewPeerInfo added in v1.10.0

func NewPeerInfo(id common.PeerId, version uint32, services uint64, relay bool, httpInfoPort uint16,
	port uint16, height uint64, softVersion string, addr string) *PeerInfo

func (*PeerInfo) RemoteListenAddress added in v1.10.0

func (pi *PeerInfo) RemoteListenAddress() string

RemoteListen get remote service port

func (*PeerInfo) String added in v1.10.0

func (self *PeerInfo) String() string

Jump to

Keyboard shortcuts

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