Skip to main content

Module rpc

Module rpc 

Source
Expand description

§High-level RPC client helpers

The user-facing side of the RPC layer. Where crate::protocol::rpc::rpc_request and crate::protocol::rpc::rpc_response deal with packet bytes, this module exposes end-to-end helpers that:

  1. Encode the request with the right PoW difficulty (higher when the peer is unknown, lower when the peer is already in the tracker — see rpc_server_known_with_requisite_pow).
  2. Dispatch over the supplied transport.
  3. Decode the response, verifying the signature over the request’s pow_content_hash — so a reply can only have come from the specific server we addressed, not a replay from another peer.
  4. Return typed payloads or an ErrorResponseV1.

Call sites either use rpc_server_unknown (first contact / bootstrap) or rpc_server_known (everything else). Trust-sensitive handlers can opt into a higher PoW floor via the _with_requisite_pow variant.

Functions§

rpc_server_known
rpc_server_known_with_no_compression
rpc_server_known_with_requisite_pow
rpc_server_known_with_requisite_pow_and_no_compression
rpc_server_unknown