lp118

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package lp118 implements the Lux Protocol 118 (LP118) for warp message handling. This is the Lux-native equivalent of ACP118.

Index

Constants

HandlerID is the protocol identifier for LP118 warp message handlers. This corresponds to SignatureRequestHandlerID in the p2p package.

Variables

This section is empty.

Functions

func NewHandlerAdapter

func NewHandlerAdapter(handler Handler) p2p.Handler

NewHandlerAdapter creates a p2p.Handler from an LP118 Handler. Since LP118 Handler already implements p2p.Handler interface, this is a simple cast.

Types

type Cache

type Cache interface {
	Get(key []byte) ([]byte, bool)
	Put(key []byte, value []byte)
}

Cache provides caching functionality.

type CachedHandler

type CachedHandler struct {
	// contains filtered or unexported fields
}

CachedHandler is a handler that caches responses.

func NewCachedHandler

func NewCachedHandler(cache Cache, verifier Verifier, signer Signer) *CachedHandler

NewCachedHandler creates a new cached handler.

func (*CachedHandler) Gossip

func (h *CachedHandler) Gossip(ctx context.Context, nodeID ids.NodeID, gossipBytes []byte)

Gossip handles gossip messages (no-op for LP118).

func (*CachedHandler) Request

func (h *CachedHandler) Request(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *p2p.Error)

Request handles an LP118 request.

type Client

type Client interface {
	// Request sends a request to a specific peer and returns the response.
	Request(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error)
}

Client is the interface for making requests to peers.

type Handler

type Handler interface {
	// Request handles an incoming application request.
	Request(ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte) ([]byte, *p2p.Error)
	// Gossip handles gossip messages (no-op for LP118).
	Gossip(ctx context.Context, nodeID ids.NodeID, gossipBytes []byte)
}

Handler handles LP118 warp message requests.

type SignatureAggregator

type SignatureAggregator struct {
	// contains filtered or unexported fields
}

SignatureAggregator aggregates warp message signatures from validators.

func NewSignatureAggregator

func NewSignatureAggregator(logger log.Logger, client Client) *SignatureAggregator

NewSignatureAggregator creates a new SignatureAggregator.

func (*SignatureAggregator) AggregateSignatures

func (a *SignatureAggregator) AggregateSignatures(
	ctx context.Context,
	msg *warp.UnsignedMessage,
	justification []byte,
	quorumNum uint64,
	quorumDen uint64,
) (*warp.Message, error)

AggregateSignatures collects signatures for the given unsigned message from validators.

func (*SignatureAggregator) RequestSignature

func (a *SignatureAggregator) RequestSignature(
	ctx context.Context,
	nodeID ids.NodeID,
	msg *warp.UnsignedMessage,
) ([]byte, error)

RequestSignature requests a signature from a specific node.

type Signer

type Signer interface {
	// Sign signs the unsigned message and returns the signature bytes.
	Sign(msg *warp.UnsignedMessage) ([]byte, error)
}

Signer signs warp messages.

type Verifier

type Verifier interface {
	// Verify verifies the unsigned message with the given justification.
	// Returns nil if verification succeeds, or an AppError if it fails.
	Verify(ctx context.Context, msg *warp.UnsignedMessage, justification []byte) *core.AppError
}

Verifier verifies warp messages.

Jump to

Keyboard shortcuts

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