shrexeds

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

This package defines a protocol that is used to request extended data squares from peers in the network.

This protocol is a request/response protocol that allows for sending requests for extended data squares by data root to the peers in the network and receiving a response containing the original data square(s), which is used to recompute the extended data square.

The streams are established using the protocol ID:

  • "{networkID}/shrex/eds/v0.0.1" where networkID is the network ID of the network. (e.g. "arabica")

When a peer receives a request for extended data squares, it will read the original data square from the EDS store by retrieving the underlying CARv1 file containing the full extended data square, but will limit reading to the original data square shares only. The client on the other hand will take care of computing the extended data squares from the original data square on receipt.

Usage

To use a shrexeds client to request extended data squares from a peer, you must first create a new `shrexeds.Client` instance by:

client, err := shrexeds.NewClient(params, host)

where `params` is a `shrexeds.Parameters` instance and `host` is a `libp2p.Host` instance.

To request extended data squares from a peer, you must first create a `Client.RequestEDS` instance by:

eds, err := client.RequestEDS(ctx, dataHash, peer)

where:

  • `ctx` is a `context.Context` instance,
  • `dataHash` is the data root of the extended data square and
  • `peer` is the peer ID of the peer to request the extended data square from.

To use a shrexeds server to respond to requests for extended data squares from peers you must first create a new `shrexeds.Server` instance by:

server, err := shrexeds.NewServer(params, host, store)

where `params` is a Parameters instance, `host` is a libp2p.Host instance and `store` is a eds.Store instance.

To start the server, you must call `Start` on the server:

err := server.Start(ctx)

To stop the server, you must call `Stop` on the server:

err := server.Stop(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is responsible for requesting EDSs for blocksync over the ShrEx/EDS protocol.

func NewClient

func NewClient(params *Parameters, host host.Host) (*Client, error)

NewClient creates a new ShrEx/EDS client.

func (*Client) RequestEDS

func (c *Client) RequestEDS(
	ctx context.Context,
	dataHash share.DataHash,
	peer peer.ID,
) (*rsmt2d.ExtendedDataSquare, error)

RequestEDS requests the ODS from the given peers and returns the EDS upon success.

func (*Client) WithMetrics added in v0.9.2

func (c *Client) WithMetrics() error

type Parameters

type Parameters struct {
	*p2p.Parameters

	// BufferSize defines the size of the buffer used for writing an ODS over the stream.
	BufferSize uint64
}

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

func DefaultParameters

func DefaultParameters() *Parameters

func (*Parameters) Validate

func (p *Parameters) Validate() error

type Server

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

Server is responsible for serving ODSs for blocksync over the ShrEx/EDS protocol.

func NewServer

func NewServer(params *Parameters, host host.Host, store *eds.Store) (*Server, error)

NewServer creates a new ShrEx/EDS server.

func (*Server) Start

func (s *Server) Start(context.Context) error

func (*Server) Stop

func (s *Server) Stop(context.Context) error

func (*Server) WithMetrics added in v0.9.2

func (s *Server) WithMetrics() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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