shrex

package
v0.18.0-not-final-expe... Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package shrex provides functionality that powers the share exchange protocols used by celestia-node. The available protocols are:

  • shrexsub : a floodsub-based pubsub protocol that is used to broadcast/subscribe to the event of new EDS in the network to peers.

  • shrexnd: a request/response protocol that is used to request shares by namespace or namespace data from peers.

  • shrexeds: a request/response protocol that is used to request extended data square shares from peers. This protocol exchanges the original data square in between the client and server, and it's up to the receiver to compute the extended data square.

This package also defines a peer manager that is used to manage network peers that can be used to exchange shares. The peer manager is primarily responsible for providing peers to request shares from, and is primarily used by `getters.ShrexGetter` in share/getters/shrex.go.

Find out more about each protocol in their respective sub-packages.

Index

Constants

View Source
const (
	StatusBadRequest  status = "bad_request"
	StatusSendRespErr status = "send_resp_err"
	StatusSendReqErr  status = "send_req_err"
	StatusReadRespErr status = "read_resp_err"
	StatusInternalErr status = "internal_err"
	StatusNotFound    status = "not_found"
	StatusTimeout     status = "timeout"
	StatusSuccess     status = "success"
	StatusRateLimited status = "rate_limited"
)
View Source
const ProtocolString = "/shrex/v0.1.0/"

protocolString is the protocol string for the shrex protocol.

Variables

View Source
var ErrInvalidResponse = errors.New("server returned an invalid response or caused an internal error")

ErrInvalidResponse is returned when a peer returns an invalid response or caused an internal error. It is used to signal that the peer couldn't serve the data successfully, and should not be retried.

View Source
var ErrNotFound = errors.New("the requested data or resource could not be found")

ErrNotFound is returned when a peer is unable to find the requested data or resource. It is used to signal that the peer couldn't serve the data successfully, and it's not available at the moment. The request may be retried later, but it's unlikely to succeed.

View Source
var ErrRateLimited = errors.New("server is overloaded and rate limited the request")

Functions

func ErrorContains

func ErrorContains(err, target error) bool

ErrorContains reports whether any error in err's tree matches any error in targets tree.

func ProtocolID

func ProtocolID(networkID, protocolString string) protocol.ID

ProtocolID creates a protocol ID string according to common format

func RecoveryMiddleware

func RecoveryMiddleware(handler network.StreamHandler) network.StreamHandler

RecoveryMiddleware is a middleware that recovers from panics in the handler.

Types

type Metrics

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

func InitClientMetrics

func InitClientMetrics(protocol string) (*Metrics, error)

func InitServerMetrics

func InitServerMetrics(protocol string) (*Metrics, error)

func (*Metrics) ObserveRequests

func (m *Metrics) ObserveRequests(ctx context.Context, count int64, status status)

ObserveRequests increments the total number of requests sent with the given status as an attribute.

type Middleware

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

func NewMiddleware

func NewMiddleware(concurrencyLimit int) *Middleware

func (*Middleware) DrainCounter

func (m *Middleware) DrainCounter() int64

DrainCounter returns the current value of the rate limit counter and resets it to 0.

func (*Middleware) RateLimitHandler

func (m *Middleware) RateLimitHandler(handler network.StreamHandler) network.StreamHandler

type Parameters

type Parameters struct {
	// ServerReadTimeout sets the timeout for reading messages from the stream.
	ServerReadTimeout time.Duration

	// ServerWriteTimeout sets the timeout for writing messages to the stream.
	ServerWriteTimeout time.Duration

	// HandleRequestTimeout defines the deadline for handling request.
	HandleRequestTimeout time.Duration

	// ConcurrencyLimit is the maximum number of concurrently handled streams
	ConcurrencyLimit int
	// contains filtered or unexported fields
}

Parameters is the set of parameters that must be configured for the shrex/eds protocol.

func DefaultParameters

func DefaultParameters() *Parameters

func (*Parameters) NetworkID

func (p *Parameters) NetworkID() string

NetworkID returns the value of networkID stored in params

func (*Parameters) Validate

func (p *Parameters) Validate() error

func (*Parameters) WithNetworkID

func (p *Parameters) WithNetworkID(networkID string)

WithNetworkID sets the value of networkID in params

Directories

Path Synopsis
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter.
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter.
This package defines a protocol that is used to request extended data squares from peers in the network.
This package defines a protocol that is used to request extended data squares from peers in the network.
This package defines a protocol that is used to request namespaced data from peers in the network.
This package defines a protocol that is used to request namespaced data from peers in the network.
This package defines a protocol that is used to broadcast shares to peers over a pubsub network.
This package defines a protocol that is used to broadcast shares to peers over a pubsub network.
pb

Jump to

Keyboard shortcuts

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