share

package
v0.28.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructModule

func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option

func WithBlockStoreMetrics added in v0.21.9

func WithBlockStoreMetrics(bs *bitswap.BlockstoreWithMetrics) error

func WithDiscoveryMetrics added in v0.9.4

func WithDiscoveryMetrics(discs []*discovery.Discovery) error

WithDiscoveryMetrics is a utility function to turn on discovery metrics and that is expected to be "invoked" by the fx lifecycle.

func WithPeerManagerMetrics added in v0.9.2

func WithPeerManagerMetrics(managers map[string]*peers.Manager) error

WithPeerManagerMetrics is a utility function to turn on peer manager metrics and that is expected to be "invoked" by the fx lifecycle.

func WithShrexClientMetrics added in v0.9.2

func WithShrexClientMetrics(client *shrex.Client) error

func WithShrexGetterMetrics added in v0.9.2

func WithShrexGetterMetrics(sg *shrex_getter.Getter) error

func WithShrexServerMetrics added in v0.9.2

func WithShrexServerMetrics(server *shrex.Server) error

func WithStoreMetrics added in v0.11.0

func WithStoreMetrics(s *store.Store) error

Types

type API added in v0.5.0

type API struct {
	Internal struct {
		SharesAvailable func(ctx context.Context, height uint64) error `perm:"read"`
		GetShare        func(
			ctx context.Context,
			height uint64,
			row, col int,
		) (libshare.Share, error) `perm:"read"`
		GetSamples func(
			ctx context.Context,
			height uint64,
			indices []shwap.SampleCoords,
		) ([]shwap.Sample, error) `perm:"read"`
		GetEDS func(
			ctx context.Context,
			height uint64,
		) (*rsmt2d.ExtendedDataSquare, error) `perm:"read"`
		GetRow func(
			context.Context,
			uint64,
			int,
		) (shwap.Row, error) `perm:"read"`
		GetNamespaceData func(
			ctx context.Context,
			height uint64,
			namespace libshare.Namespace,
		) (shwap.NamespaceData, error) `perm:"read"`
		GetRange func(
			ctx context.Context,
			height uint64,
			start, end int,
		) (*GetRangeResult, error) `perm:"read"`
	}
}

API is a wrapper around Module for the RPC.

func (*API) GetEDS added in v0.6.2

func (api *API) GetEDS(ctx context.Context, height uint64) (*rsmt2d.ExtendedDataSquare, error)

func (*API) GetNamespaceData added in v0.20.2

func (api *API) GetNamespaceData(
	ctx context.Context,
	height uint64,
	namespace libshare.Namespace,
) (shwap.NamespaceData, error)

func (*API) GetRange added in v0.15.0

func (api *API) GetRange(ctx context.Context, height uint64, from, to int,
) (*GetRangeResult, error)

func (*API) GetRow added in v0.21.5

func (api *API) GetRow(ctx context.Context, height uint64, rowIdx int) (shwap.Row, error)

func (*API) GetSamples added in v0.20.4

func (api *API) GetSamples(ctx context.Context, height uint64,
	indices []shwap.SampleCoords,
) ([]shwap.Sample, error)

func (*API) GetShare added in v0.5.0

func (api *API) GetShare(ctx context.Context, height uint64, row, col int) (libshare.Share, error)

func (*API) SharesAvailable added in v0.5.0

func (api *API) SharesAvailable(ctx context.Context, height uint64) error

type Config

type Config struct {
	// EDSStoreParams sets eds store configuration parameters
	EDSStoreParams      *store.Parameters
	BlockStoreCacheSize uint

	UseShareExchange bool
	UseBitswap       bool

	// Shrex sets client and server configuration parameters of the shrex protocol
	ShrexClient *shrex.ClientParams
	ShrexServer *shrex.ServerParams
	// PeerManagerParams sets peer-manager configuration parameters
	PeerManagerParams *peers.Parameters

	LightAvailability *light.Parameters `toml:",omitempty"`
	Discovery         *discovery.Parameters
}

func DefaultConfig

func DefaultConfig(tp node.Type) Config

func (*Config) Validate

func (cfg *Config) Validate(tp node.Type) error

Validate performs basic validation of the config.

type GetRangeResult added in v0.15.0

type GetRangeResult struct {
	// Shares contains the data shares retrieved from the specified range.
	Shares []libshare.Share
	// Proof proves that shares were included in the data root.
	Proof *types.ShareProof
}

GetRangeResult wraps the return value of the GetRange endpoint because Json-RPC doesn't support more than two return values.

func (*GetRangeResult) MarshalJSON added in v0.25.3

func (r *GetRangeResult) MarshalJSON() ([]byte, error)

MarshalJSON marshals an GetRangeResult to JSON. Uses tendermint encoder for proof for compatibility.

func (*GetRangeResult) UnmarshalJSON added in v0.25.3

func (r *GetRangeResult) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals an GetRangeResult from JSON. Uses tendermint decoder for proof for compatibility.

func (*GetRangeResult) Verify added in v0.25.3

func (r *GetRangeResult) Verify(dataRoot []byte) error

Verify verifies inclusion the data in the data root

type Module

type Module interface {
	// SharesAvailable performs a subjective validation to check if the shares committed to
	// the ExtendedHeader at the specified height are available and retrievable from the network.
	// Returns an error if the shares are not available or if validation fails.
	SharesAvailable(ctx context.Context, height uint64) error

	// GetShare retrieves a specific share from the Extended Data Square (EDS) at the given height
	// using its row and column coordinates. Returns the share data or an error if retrieval fails.
	GetShare(ctx context.Context, height uint64, rowIdx, colIdx int) (libshare.Share, error)

	// GetSamples retrieves multiple shares from the Extended Data Square (EDS) specified by the header
	// at the given sample coordinates. Returns an array of samples containing the requested shares
	// or an error if retrieval fails.
	GetSamples(ctx context.Context, height uint64, indices []shwap.SampleCoords) ([]shwap.Sample, error)

	// GetEDS retrieves the complete Extended Data Square (EDS) for the specified height.
	// The EDS contains all shares organized in a 2D matrix format with erasure coding.
	// Returns the full EDS or an error if retrieval fails.
	GetEDS(ctx context.Context, height uint64) (*rsmt2d.ExtendedDataSquare, error)

	// GetRow retrieves all shares from a specific row in the Extended Data Square (EDS)
	// at the given height. Returns the complete row of shares or an error if retrieval fails.
	GetRow(ctx context.Context, height uint64, rowIdx int) (shwap.Row, error)

	// GetNamespaceData retrieves all shares that belong to the specified namespace within
	// the Extended Data Square (EDS) at the given height. The shares are returned in a
	// row-by-row order, maintaining the original layout if the namespace spans multiple rows.
	// Returns the namespace data or an error if retrieval fails.
	GetNamespaceData(
		ctx context.Context,
		height uint64,
		namespace libshare.Namespace,
	) (shwap.NamespaceData, error)

	// GetRange retrieves a range of the *original* shares and their corresponding proofs within a specific
	// namespace in the Extended Data Square (EDS) at the given height. The range is defined
	// by start and end indexes. Returns the range data with proof to the data root or an error if retrieval fails.
	GetRange(
		ctx context.Context,
		height uint64,
		start, end int,
	) (*GetRangeResult, error)
}

Module provides access to any data square or block share on the network.

All Get methods provided on Module follow the following flow:

  1. Check local storage for the requested share.
  2. If exists * Load from disk * Return
  3. If not * Find provider on the network * Fetch the Share from the provider * Store the Share * Return

Any method signature changed here needs to also be changed in the API struct.

type Window added in v0.20.2

type Window time.Duration

Window is a type alias for time.Duration used in nodebuilder to provide sampling windows to their relevant components

func (Window) Duration added in v0.20.2

func (w Window) Duration() time.Duration

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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