peering

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0, BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// equal and larger msg types are committee messages
	// those with smaller are reserved by the package for heartbeat and handshake messages
	FirstCommitteeMsgCode = byte(0x10)

	MsgTypeReserved  = byte(0)
	MsgTypeHandshake = byte(1)
	MsgTypeMsgChunk  = byte(2)
)
View Source
const PluginName = "Peering"

PluginName is the name of the database plugin.

Variables

View Source
var EventPeerMessageReceived = events.NewEvent(func(handler interface{}, params ...interface{}) {
	handler.(func(_ *PeerMessage))(params[0].(*PeerMessage))
})

Functions

func Init

func Init() *node.Plugin

func MyNetworkId

func MyNetworkId() string

func SendMsgToPeers

func SendMsgToPeers(msg *PeerMessage, ts int64, peers ...*Peer) uint16

SendMsgToPeers sends same msg to all peers in the slice which are not nil with the same timestamp return number of successfully sent messages and timestamp

func StopUsingPeer

func StopUsingPeer(peerId string)

decreases counter

Types

type Peer

type Peer struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

represents point-to-point TCP connection between two qnodes and another it is used as transport for message exchange Another end is always using the same connection the Peer takes care about exchanging heartbeat messages. It keeps last several received heartbeats as "lad" data to be able to calculate how synced/unsynced clocks of peer are.

func UsePeer

func UsePeer(remoteLocation string) *Peer

adds new connection to the peer pool if it already exists, returns existing connection added to the pool is picked by loops which will try to establish connection

func (*Peer) IsAlive

func (peer *Peer) IsAlive() bool

return true if is alive and average latencyRingBuf in nanosec

func (*Peer) NumUsers

func (peer *Peer) NumUsers() int

func (*Peer) PeeringId

func (peer *Peer) PeeringId() string

func (*Peer) SendMsg

func (peer *Peer) SendMsg(msg *PeerMessage) error

type PeerMessage

type PeerMessage struct {
	Address     address.Address
	SenderIndex uint16
	Timestamp   int64
	MsgType     byte
	MsgData     []byte
}

type PeerStatus

type PeerStatus struct {
	RemoteLocation string
	IsInbound      bool
	IsAlive        bool
	NumUsers       int
}

type Status

type Status struct {
	MyNetworkId string
	Peers       []*PeerStatus
}

func GetStatus

func GetStatus() *Status

Jump to

Keyboard shortcuts

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