Skip to main content

Module handler

Module handler 

Source
Expand description

The RpcHandler trait โ€” the seam a DIG node implements.

dig-rpc owns the transport, the JSON-RPC envelope, the method-known / tier / allowlist boundary, and rate limiting. It does NOT know how to serve content, resolve a chain-anchored root, or read a store โ€” the consuming node (the digstore dig-node crate, the standalone binary) supplies that via this one small async trait. This is why dig-rpc depends only on dig_rpc_protocol, never on a node/service crate.

A handler receives a resolved Method plus its raw params Value and returns either a result Value or a canonical RpcError. By the time the handler is called, the dispatcher has already:

  1. rejected unknown methods with -32601;
  2. enforced the Tier boundary (a non-allowlisted method on the peer surface is -32601; a control method off the loopback surface is -32030);
  3. applied rate limiting.

So a handler implements only the method semantics, not the boundary.

Traitsยง

RpcHandler
The node behind the RPC server.