share

package
v0.18.0-rc22 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: Apache-2.0 Imports: 43 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 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(edsClient *shrexeds.Client, ndClient *shrexnd.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(edsServer *shrexeds.Server, ndServer *shrexnd.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(context.Context, *header.ExtendedHeader) error `perm:"read"`
		GetShare        func(
			ctx context.Context,
			header *header.ExtendedHeader,
			row, col int,
		) (share.Share, error) `perm:"read"`
		GetEDS func(
			ctx context.Context,
			header *header.ExtendedHeader,
		) (*rsmt2d.ExtendedDataSquare, error) `perm:"read"`
		GetSharesByNamespace func(
			ctx context.Context,
			header *header.ExtendedHeader,
			namespace share.Namespace,
		) (NamespacedShares, error) `perm:"read"`
		GetRange func(
			ctx context.Context,
			height uint64,
			start, end int,
		) (*GetRangeResult, error) `perm:"read"`
		BitswapActiveFetches func(
			ctx context.Context,
		) ([]cid.Cid, error) `perm:"admin"`
	}
}

API is a wrapper around Module for the RPC. TODO(@distractedm1nd): These structs need to be autogenerated.

func (*API) BitswapActiveFetches

func (api *API) BitswapActiveFetches(ctx context.Context) ([]cid.Cid, error)

func (*API) GetEDS added in v0.6.2

func (api *API) GetEDS(ctx context.Context, header *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error)

func (*API) GetRange added in v0.15.0

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

func (*API) GetShare added in v0.5.0

func (api *API) GetShare(ctx context.Context, header *header.ExtendedHeader, row, col int) (share.Share, error)

func (*API) GetSharesByNamespace added in v0.5.0

func (api *API) GetSharesByNamespace(
	ctx context.Context,
	header *header.ExtendedHeader,
	namespace share.Namespace,
) (NamespacedShares, error)

func (*API) SharesAvailable added in v0.5.0

func (api *API) SharesAvailable(ctx context.Context, header *header.ExtendedHeader) error

type Config

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

	UseShareExchange bool
	// ShrExEDSParams sets shrexeds client and server configuration parameters
	ShrExEDSParams *shrexeds.Parameters
	// ShrExNDParams sets shrexnd client and server configuration parameters
	ShrExNDParams *shrexnd.Parameters
	// PeerManagerParams sets peer-manager configuration parameters
	PeerManagerParams peers.Parameters

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

TODO: some params are pointers and other are not, Let's fix this.

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 []share.Share
	Proof  *types.ShareProof
}

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

type Module

type Module interface {
	// SharesAvailable subjectively validates if Shares committed to the given
	// ExtendedHeader are available on the Network.
	SharesAvailable(context.Context, *header.ExtendedHeader) error
	// GetShare gets a Share by coordinates in EDS.
	GetShare(ctx context.Context, header *header.ExtendedHeader, row, col int) (share.Share, error)
	// GetEDS gets the full EDS identified by the given extended header.
	GetEDS(ctx context.Context, header *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error)
	// GetSharesByNamespace gets all shares from an EDS within the given namespace.
	// Shares are returned in a row-by-row order if the namespace spans multiple rows.
	GetSharesByNamespace(
		ctx context.Context, header *header.ExtendedHeader, namespace share.Namespace,
	) (NamespacedShares, error)
	// GetRange gets a list of shares and their corresponding proof.
	GetRange(ctx context.Context, height uint64, start, end int) (*GetRangeResult, error)
	BitswapActiveFetches(ctx context.Context) ([]cid.Cid, 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 NamespacedRow

type NamespacedRow struct {
	Shares []share.Share `json:"shares"`
	Proof  *nmt.Proof    `json:"proof"`
}

NamespacedRow represents all shares with proofs within a specific namespace of a single EDS row.

type NamespacedShares

type NamespacedShares []NamespacedRow

NamespacedShares represents all shares with proofs within a specific namespace of an EDS. This is a copy of the share.NamespacedShares type, that is used to avoid breaking changes in the API.

func (NamespacedShares) Flatten

func (ns NamespacedShares) Flatten() []share.Share

Flatten returns the concatenated slice of all NamespacedRow shares.

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