Run NodesReferenceDb

rpcdb

Package rpcdb is luxd's canonical Layer C home for the rpcdb service: one Service implementation backed by a database.Database, with a transport adapter per supported wire protocol.

import "github.com/luxfi/node/db/rpcdb"

Package rpcdb is luxd's canonical Layer C home for the rpcdb service: one Service implementation backed by a database.Database, with a transport adapter per supported wire protocol.

Layered topology:

Layer A — wire framing (github.com/luxfi/api/zap) Layer B — service spec (data carriers) (github.com/luxfi/proto/rpcdb) Layer C — service impl + transports (this package)

One Service. Many transport adapters. Adding a new transport is a new file that wraps *Service; the storage logic stays here and stays orthogonal to framing concerns.

Files:

  • service.go (this) — transport-neutral Service struct + methods
  • grpc_server.go (build tag grpc) — gRPC adapter
  • zap_server.go (default) — ZAP adapter

Functions

CodeToErr

func CodeToErr(code rpcdb.Error) error

CodeToErr maps a wire-typed Error back to a database sentinel. Used by remote clients on the receive side; lives here so server and client agree on the inverse of errToCode.

Types

Service

Service is the rpcdb service implementation. It holds one database.Database and a server-managed iterator pool, and exposes every rpcdb operation as a (request → response) method on Go data carriers from the proto/rpcdb wire-types package.

Service is transport-agnostic: it knows nothing about gRPC, ZAP, or any other framing. Each transport adapter wraps *Service and translates its own wire format into these method calls.

func NewService(db database.Database) *Service
func (s *Service) Close(_ context.Context, _ *rpcdb.CloseRequest) (*rpcdb.CloseResponse, error)
func (s *Service) CloseIterators()
func (s *Service) Compact(_ context.Context, req *rpcdb.CompactRequest) (*rpcdb.CompactResponse, error)
func (s *Service) DB() database.Database
func (s *Service) Delete(_ context.Context, req *rpcdb.DeleteRequest) (*rpcdb.DeleteResponse, error)
func (s *Service) Get(_ context.Context, req *rpcdb.GetRequest) (*rpcdb.GetResponse, error)
func (s *Service) Has(_ context.Context, req *rpcdb.HasRequest) (*rpcdb.HasResponse, error)
func (s *Service) HealthCheck(ctx context.Context) (*rpcdb.HealthCheckResponse, error)
func (s *Service) IteratorError(_ context.Context, req *rpcdb.IteratorErrorRequest) (*rpcdb.IteratorErrorResponse, error)
func (s *Service) IteratorNext(_ context.Context, req *rpcdb.IteratorNextRequest) (*rpcdb.IteratorNextResponse, error)
func (s *Service) IteratorRelease(_ context.Context, req *rpcdb.IteratorReleaseRequest) (*rpcdb.IteratorReleaseResponse, error)
func (s *Service) NewIteratorWithStartAndPrefix(_ context.Context, req *rpcdb.NewIteratorWithStartAndPrefixRequest) (*rpcdb.NewIteratorWithStartAndPrefixResponse, error)
func (s *Service) Put(_ context.Context, req *rpcdb.PutRequest) (*rpcdb.PutResponse, error)
func (s *Service) WriteBatch(_ context.Context, req *rpcdb.WriteBatchRequest) (*rpcdb.WriteBatchResponse, error)

ZAPServer

ZAPServer is the ZAP transport adapter for the rpcdb Service. It owns the listener and the dispatch loop; the actual storage logic lives in *Service. To swap the wire format (eg. to add framing over a different reliable byte stream) write a new file with a new adapter — never edit Service.

func NewZAPServer(db database.Database) *ZAPServer
func NewZAPServerFromService(svc *Service) *ZAPServer
func (s *ZAPServer) Addr() net.Addr
func (s *ZAPServer) Close() error
func (s *ZAPServer) Listen(addr string) error
func (s *ZAPServer) ListenOn(raw net.Listener)
func (s *ZAPServer) Serve(ctx context.Context) error