protocolp2p

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNetworkIsNotReady is returned when trying to access the network instance before it's ready
	ErrNetworkIsNotReady = errors.New("network services are not ready")
)

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	p2p.Broadcaster
}

Broadcaster enables to broadcast messages

type MsgValidationResult

type MsgValidationResult int32

MsgValidationResult helps other components to report message validation with a generic results scheme

const (
	// ValidationAccept is the result of a valid message
	ValidationAccept MsgValidationResult = iota
	// ValidationIgnore is the result in case we want to ignore the validation
	ValidationIgnore
	// ValidationRejectLow is the result for invalid message, with low severity (e.g. late message)
	ValidationRejectLow
	// ValidationRejectMedium is the result for invalid message, with medium severity (e.g. wrong height)
	ValidationRejectMedium
	// ValidationRejectHigh is the result for invalid message, with high severity (e.g. invalid signature)
	ValidationRejectHigh
)

type Network

type Network interface {
	Subscriber
	Broadcaster
	ValidationReporting

	// RegisterHandlers registers handler for the given protocol
	RegisterHandlers(logger *zap.Logger, handlers ...*SyncHandler)
}

Network holds the networking layer used to complement the underlying protocols

type RequestHandler

type RequestHandler func(*spectypes.SSVMessage) (*spectypes.SSVMessage, error)

RequestHandler handles p2p requests

func CombineRequestHandlers

func CombineRequestHandlers(handlers ...RequestHandler) RequestHandler

CombineRequestHandlers combines multiple handlers into a single handler

type Subscriber

type Subscriber interface {
	p2p.Subscriber
	// Unsubscribe unsubscribes from the validator subnet
	Unsubscribe(logger *zap.Logger, pk spectypes.ValidatorPK) error
	// Peers returns the peers that are connected to the given validator
	Peers(pk spectypes.ValidatorPK) ([]peer.ID, error)
}

Subscriber manages topics subscription

type SyncHandler

type SyncHandler struct {
	Protocol SyncProtocol
	Handler  RequestHandler
}

SyncHandler is a wrapper for RequestHandler, that enables to specify the protocol

func WithHandler

func WithHandler(protocol SyncProtocol, handler RequestHandler) *SyncHandler

WithHandler enables to inject an SyncHandler

type SyncProtocol

type SyncProtocol int32

SyncProtocol represent the type of sync protocols

const (
	// LastDecidedProtocol is the last decided protocol type
	LastDecidedProtocol SyncProtocol = iota
	// DecidedHistoryProtocol is the decided history protocol type
	DecidedHistoryProtocol
)

type SyncResult

type SyncResult struct {
	Msg    *spectypes.SSVMessage
	Sender string
}

SyncResult holds the result of a sync request, including the actual message and the sender

type SyncResults

type SyncResults []SyncResult

func (SyncResults) ForEachSignedMessage

func (results SyncResults) ForEachSignedMessage(iterator func(message *specqbft.SignedMessage) (stop bool))

func (SyncResults) String added in v0.4.7

func (s SyncResults) String() string

String method was created for logging purposes

type ValidationReporting

type ValidationReporting interface {
	// ReportValidation reports the result for the given message
	ReportValidation(logger *zap.Logger, message *spectypes.SSVMessage, res MsgValidationResult)
}

ValidationReporting is the interface for reporting on message validation results

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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