You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// implements actual logic to read and write from node network
type availabilityService struct {}
// performs network ops to get the data
func (availability) GetByNamespace(context.Context, namespace.ID, Root) ([][]byte, error)
// sends PFD
func (availability) SubmitData(context.Context, namespace.ID, [][]byte) (Root, error)
With Open/JSONRPC tooling we are aware of, we can do this:
server := jsonrpc.NewServer(...)
server.Register(new(DataAvailability), &availabilityService{})
server.Serve()
This is almost all you need to do to set up your own RPC server. The tooling parses the given interface and automagically setups the endpoint for each existing method.
Similarly on the client side:
client := jsonrpc.NewClient(serverAddr, new(DataAvailability))
client.GetByNamespace() // does request to the remote server instance of DataAvailabiliy interface and returns the results
Simple, powerful, and composable.
With regular Rest APIs there is a lot of boilerplate code that you cannot avoid. GRPC is somewhat similar to RPC, but it generates interfaces for you, which I personally hate. Interfaces have to be handwritten with care and succinctness and cohesionin mind
Context
This issue supersedes and encompasses #169, serving as the canonical tracking issue for work related to celestia-node API.
Current design
Simple HTTP server with endpoints accessing certain methods mounted on the servemux. See here.
Desired design
An RPC client that provides modules based on the services provided by the node.
Goals
Issue breakdown
Node
pkg refactoring #958fraud.Subscribe
should return a channel ofProof
s #1207fraud.Proof
andExtendedHeader
s #1208nodebuilder/<pkg>/service.go
files to respective package name #1278Config
usage pattern #1287log
loggers to$MODULENAME/constructor
instead of$MODULENAME-module
#1288Related issues
The text was updated successfully, but these errors were encountered: