qlight

package
v0.0.0-...-1d3cd56 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QLightStatusMsg              = 0x11
	QLightTokenUpdateMsg         = 0x12
	QLightNewBlockPrivateDataMsg = 0x13
)
View Source
const ProtocolName = "qlight"
View Source
const QLIGHT65 = 65
View Source
const QLightProtocolLength = 20

Variables

This section is empty.

Functions

func HandleClient

func HandleClient(backend Backend, peer *Peer) error

Handle is invoked whenever an `eth` connection is made that successfully passes the protocol handshake. This method will keep processing messages until the connection is torn down.

func HandleServer

func HandleServer(backend Backend, peer *Peer) error

func MakeProtocolsClient

func MakeProtocolsClient(backend Backend, network uint64, dnsdisc enode.Iterator) []p2p.Protocol

MakeProtocols constructs the P2P protocol definitions for `eth`.

func MakeProtocolsServer

func MakeProtocolsServer(backend Backend, network uint64, dnsdisc enode.Iterator) []p2p.Protocol

MakeProtocolsServer constructs the P2P protocol definitions for `qlight` server.

Types

type Backend

type Backend interface {
	eth.Backend
	// RunPeer is invoked when a peer joins on the `eth` protocol. The handler
	// should do any peer maintenance work, handshakes and validations. If all
	// is passed, control should be given back to the `handler` to process the
	// inbound messages going forward.
	RunQPeer(peer *Peer, handler Handler) error
	// Handle is a callback to be invoked when a data packet is received from
	// the remote peer. Only packets not consumed by the protocol handler will
	// be forwarded to the backend.
	QHandle(peer *Peer, packet eth.Packet) error
}

Backend defines the data retrieval methods to serve remote requests and the callback methods to invoke on remote deliveries.

type BlockPrivateDataPacket

type BlockPrivateDataPacket []qlight.BlockPrivateData

func (*BlockPrivateDataPacket) Kind

func (*BlockPrivateDataPacket) Kind() byte

func (*BlockPrivateDataPacket) Name

type Handler

type Handler func(peer *Peer) error

Handler is a callback to invoke from an outside runner after the boilerplate exchanges have passed.

type Peer

type Peer struct {
	*p2p.Peer // The embedded P2P package peer

	EthPeer *eth.Peer

	QLightPeriodicAuthFunc func() error
	// contains filtered or unexported fields
}

Peer is a collection of relevant information we have about a `snap` peer.

func NewPeer

func NewPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, ethPeer *eth.Peer) *Peer

newPeer create a wrapper for a network connection and negotiated protocol version.

func NewPeerWithBlockBroadcast

func NewPeerWithBlockBroadcast(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, ethPeer *eth.Peer) *Peer

func (*Peer) AsyncSendNewBlock

func (p *Peer) AsyncSendNewBlock(block *types.Block, td *big.Int, blockPrivateData *qlight.BlockPrivateData)

AsyncSendNewBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) Close

func (p *Peer) Close()

func (*Peer) ID

func (p *Peer) ID() string

ID retrieves the peer's unique identifier.

func (*Peer) KnownBlock

func (p *Peer) KnownBlock(hash common.Hash) bool

KnownBlock returns whether peer is known to already have a block.

func (*Peer) Log

func (p *Peer) Log() log.Logger

Log overrides the P2P logget with the higher level one containing only the id.

func (*Peer) PeriodicAuthCheck

func (p *Peer) PeriodicAuthCheck()

func (*Peer) QLightHandshake

func (p *Peer) QLightHandshake(server bool, psi string, token string) error

func (*Peer) QLightPSI

func (p *Peer) QLightPSI() string

func (*Peer) QLightServer

func (p *Peer) QLightServer() bool

func (*Peer) QLightToken

func (p *Peer) QLightToken() string

func (*Peer) SendBlockPrivateData

func (p *Peer) SendBlockPrivateData(data []qlight.BlockPrivateData) error

func (*Peer) SendNewAuthToken

func (p *Peer) SendNewAuthToken(token string) error

func (*Peer) SendNewBlock

func (p *Peer) SendNewBlock(block *types.Block, td *big.Int) error

func (*Peer) Version

func (p *Peer) Version() uint

Version retrieves the peer's negoatiated `snap` protocol version.

Jump to

Keyboard shortcuts

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