share

package
v0.0.0-...-4e9d6c2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 26 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

func WithDiscoveryMetrics(d *disc.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

func WithPeerManagerMetrics(m *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

func WithShrexClientMetrics(edsClient *shrexeds.Client, ndClient *shrexnd.Client) error

func WithShrexGetterMetrics

func WithShrexGetterMetrics(sg *getters.ShrexGetter) error

func WithShrexServerMetrics

func WithShrexServerMetrics(edsServer *shrexeds.Server, ndServer *shrexnd.Server) error

Types

type API

type API struct {
	Internal struct {
		SharesAvailable           func(context.Context, *share.Root) error `perm:"public"`
		ProbabilityOfAvailability func(context.Context) float64            `perm:"public"`
		GetShare                  func(
			ctx context.Context,
			dah *share.Root,
			row, col int,
		) (share.Share, error) `perm:"public"`
		GetEDS func(
			ctx context.Context,
			root *share.Root,
		) (*rsmt2d.ExtendedDataSquare, error) `perm:"public"`
		GetSharesByNamespace func(
			ctx context.Context,
			root *share.Root,
			namespace namespace.ID,
		) (share.NamespacedShares, error) `perm:"public"`
	}
}

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

func (*API) GetEDS

func (api *API) GetEDS(ctx context.Context, root *share.Root) (*rsmt2d.ExtendedDataSquare, error)

func (*API) GetShare

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

func (*API) GetSharesByNamespace

func (api *API) GetSharesByNamespace(
	ctx context.Context,
	root *share.Root,
	namespace namespace.ID,
) (share.NamespacedShares, error)

func (*API) ProbabilityOfAvailability

func (api *API) ProbabilityOfAvailability(ctx context.Context) float64

func (*API) SharesAvailable

func (api *API) SharesAvailable(ctx context.Context, root *share.Root) error

type Config

type Config struct {
	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 Module

type Module interface {
	// SharesAvailable subjectively validates if Shares committed to the given Root are available on
	// the Network.
	SharesAvailable(context.Context, *share.Root) error
	// ProbabilityOfAvailability calculates the probability of the data square
	// being available based on the number of samples collected.
	ProbabilityOfAvailability(context.Context) float64
	// GetShare gets a Share by coordinates in EDS.
	GetShare(ctx context.Context, dah *share.Root, row, col int) (share.Share, error)
	// GetEDS gets the full EDS identified by the given root.
	GetEDS(ctx context.Context, root *share.Root) (*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, root *share.Root, namespace namespace.ID) (share.NamespacedShares, 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.

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