shrexnd

package
v0.15.1-beta.0 Latest Latest
Warning

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

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

Documentation

Overview

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

This protocol is a request/response protocol that sends a request for specific data that lives in a specific namespace ID and receives a response with the data.

The streams are established using the protocol ID:

  • "{networkID}/shrex/nd/0.0.1" where networkID is the network ID of the network. (e.g. "arabica")

The protocol uses protobuf to serialize and deserialize messages.

Usage

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

1. Create a new client using `NewClient` and pass in the parameters of the protocol and the host:

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

2. Request data from a peer by calling Client.RequestND on the client and pass in the context, the data root, the namespace ID and the peer ID:

data, err := client.RequestND(ctx, dataRoot, peerID, namespaceID)

where data is of type share.NamespacedShares

To use a shrexnd server to respond to requests from peers, you must first create a new `shrexnd.Server` instance by:

1. Create a new server using `NewServer` and pass in the parameters of the protocol, the host, the store and store share getter:

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

where store is of type share.Store and storeShareGetter is of type share.Getter

2. Start the server by calling `Start` on the server:

err := server.Start(ctx)

3. Stop the server by calling `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 implements client side of shrex/nd protocol to obtain namespaced shares data from remote peers.

func NewClient

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

NewClient creates a new shrEx/nd client

func (*Client) RequestND added in v0.6.3

func (c *Client) RequestND(
	ctx context.Context,
	root *share.Root,
	namespace share.Namespace,
	peer peer.ID,
) (share.NamespacedShares, error)

RequestND requests namespaced data from the given peer. Returns NamespacedShares with unverified inclusion proofs against the share.Root.

func (*Client) WithMetrics added in v0.9.2

func (c *Client) WithMetrics() error

type Parameters

type Parameters = p2p.Parameters

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

func DefaultParameters

func DefaultParameters() *Parameters

type Server

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

Server implements server side of shrex/nd protocol to serve namespaced share to remote peers.

func NewServer

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

NewServer creates new Server

func (*Server) SetHandler added in v0.11.0

func (srv *Server) SetHandler(handler network.StreamHandler)

SetHandler sets server handler

func (*Server) Start

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

Start starts the server

func (*Server) Stop

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

Stop stops the server

func (*Server) WithMetrics added in v0.9.2

func (srv *Server) WithMetrics() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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