github.com/celestiaorg/celestia-node@v0.15.0-beta.1/share/p2p/shrexnd/doc.go (about)

     1  // This package defines a protocol that is used to request namespaced data from peers in the network.
     2  //
     3  // This protocol is a request/response protocol that sends a request for specific data that
     4  // lives in a specific namespace ID and receives a response with the data.
     5  //
     6  // The streams are established using the protocol ID:
     7  //
     8  //   - "{networkID}/shrex/nd/0.0.1" where networkID is the network ID of the network. (e.g. "arabica")
     9  //
    10  // The protocol uses protobuf to serialize and deserialize messages.
    11  //
    12  // # Usage
    13  //
    14  // To use a shrexnd client to request data from a peer, you must first create a new `shrexnd.Client` instance by:
    15  //
    16  // 1. Create a new client using `NewClient` and pass in the parameters of the protocol and the host:
    17  //
    18  //	client, err := shrexnd.NewClient(params, host)
    19  //
    20  // 2. Request data from a peer by calling [Client.RequestND] on the client and
    21  // pass in the context, the data root, the namespace ID and the peer ID:
    22  //
    23  //	data, err := client.RequestND(ctx, dataRoot, peerID, namespaceID)
    24  //
    25  // where data is of type [share.NamespacedShares]
    26  //
    27  // To use a shrexnd server to respond to requests from peers, you must first create a new `shrexnd.Server` instance by:
    28  //
    29  // 1. Create a new server using `NewServer` and pass in the parameters of
    30  // the protocol, the host, the store and store share getter:
    31  //
    32  //	server, err := shrexnd.NewServer(params, host, store, storeShareGetter)
    33  //
    34  // where store is of type [share.Store] and storeShareGetter is of type [share.Getter]
    35  //
    36  // 2. Start the server by calling `Start` on the server:
    37  //
    38  //	err := server.Start(ctx)
    39  //
    40  // 3. Stop the server by calling `Stop` on the server:
    41  //
    42  //	err := server.Stop(ctx)
    43  package shrexnd