Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 Syncer ValidationReporting }
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 Syncer ¶
type Syncer interface { specqbft.Syncer // GetHistory sync the given range from a set of peers that supports history for the given identifier // it accepts a list of targets for the request. GetHistory(logger *zap.Logger, mid spectypes.MessageID, from, to specqbft.Height, targets ...string) ([]SyncResult, specqbft.Height, error) // RegisterHandlers registers handler for the given protocol RegisterHandlers(logger *zap.Logger, handlers ...*SyncHandler) // LastDecided fetches last decided from a random set of peers // TODO: replace with specqbft.SyncHighestDecided LastDecided(logger *zap.Logger, mid spectypes.MessageID) ([]SyncResult, error) }
Syncer holds the interface for syncing data from other peers
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