sigil-node · rpc_server
Source declarations, signatures and documentation for rpc_server.
Source: sigil/node/sigil-node/src/rpc_server.rs. SHA-256: 41199e81730e6a55193ebc3d9503a2fe660313d46c295eb2a81ecf62023d6882.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
rpc_server::RpcRequest
JSON-RPC request envelope.
#[derive(Debug, Deserialize)]
pub struct RpcRequest {
/// JSON-RPC version (always "2.0").
pub jsonrpc: String,
/// Method name.
pub method: String,
/// Request parameters (optional).
#[serde(default)]
pub params: serde_json::Value,
/// Request ID.
pub id: serde_json::Value
}Source line: 18.
rpc_server::RpcResponse
JSON-RPC response envelope.
#[derive(Debug, Serialize)]
pub struct RpcResponse {
/// JSON-RPC version.
pub jsonrpc: String,
/// Result (mutually exclusive with error).
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<Box<serde_json::Value>>,
/// Error (mutually exclusive with result).
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<Box<RpcError>>,
/// Request ID echoed back.
pub id: Box<serde_json::Value>
}Source line: 32.
rpc_server::RpcError
JSON-RPC error object.
#[derive(Debug, Serialize)]
pub struct RpcError {
pub code: i64,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>
}Source line: 47.
rpc_server::StateQueryGate
Shared fail-closed gate for state-backed RPC queries.
#[derive(Clone, Debug)]
pub struct StateQueryGate(std::sync::Arc<std::sync::atomic::AtomicBool>);Source line: 80.
rpc_server::StateQueryGate::new
pub fn new(safe: bool) -> Self;Source line: 83.
rpc_server::StateQueryGate::is_safe
pub fn is_safe(&self) -> bool;Source line: 89.
rpc_server::StateQueryGate::set_safe
pub fn set_safe(&self, safe: bool);Source line: 93.
rpc_server::RpcState
Shared state for RPC handlers.
#[derive(Clone)]
pub struct RpcState {
pub mempool: Arc<RwLock<Mempool>>,
pub chain_id: String,
pub node_version: String,
/// Optional execution state for query methods (identity, validator, etc.).
pub execution_state: Option<Arc<dyn crate::executor::ExecutionState>>,
/// Whether state-backed RPC queries may be served from `execution_state`.
///
/// Validator/producer nodes execute the canonical chain locally, so this is
/// true there. RPC/archive mirrors that only pulled block headers/bodies but
/// have not replayed state must set this false and fail closed.
pub state_queries_safe: StateQueryGate,
/// Channel for forwarding consensus messages to the coordinator.
pub consensus_tx:
Option<tokio::sync::mpsc::Sender<crate::consensus_coordinator::InboundConsensusMsg>>,
/// Optional block store for block queries.
pub block_store: Option<Arc<dyn sigil_storage::BlockStore>>,
/// Local Weft publish/fetch/serve substrate for off-chain artifacts.
pub weft_store: Arc<crate::weave::LocalWeftArtifactStore>,
/// Engine reference for Tower attestation dispatch.
///
/// When set, the `sigil_tower_attestation` RPC method delivers inbound
/// attestations directly into `BlockEngine::on_tower_attestation_received`,
/// which verifies the signature and advances the Casper FFG finality state.
pub tower_engine: Option<Arc<crate::engine::BlockEngine>>,
/// Agent 05 D4 — RPC profile (`public` or `validator`). Defaults to
/// `Validator` for backwards compatibility with existing single-binary
/// deployments. Public-RPC pods set `--rpc-profile public` so
/// validator-internal methods (`sigil_consensus_*`,
/// `sigil_tower_attestation`) return `MethodNotFound`.
pub rpc_profile: crate::rpc_middleware::RpcProfile
}Source line: 106.
rpc_server::serve
Start the RPC server on the given address.
This function blocks until the server is shut down.
pub async fn serve(addr: String, state: RpcState) -> Result<(), NodeError>;Source line: 159.
rpc_server::bind
Bind the RPC listener before spawning the server task.
sigil-node uses this in main.rs so startup fails if the configured
address is already occupied.
pub async fn bind(addr: &str) -> Result<tokio::net::TcpListener, NodeError>;Source line: 168.
rpc_server::serve_listener
Serve RPC traffic on an already-bound listener.
Splitting bind from serve lets startup propagate bind failures while still running the HTTP server concurrently with the node engine.
pub async fn serve_listener(
listener: tokio::net::TcpListener,
state: RpcState,
) -> Result<(), NodeError>;Source line: 178.
rpc_server::router
Build the axum Router for the Sigil RPC surface.
Extracted from serve_listener so the conformance test in
tests/rpc_conformance.rs can exercise the dispatcher without
binding a TCP listener. Returns an Err only if the rate-limit
configuration is invalid (per_second × burst_size rejects).
pub fn router(state: RpcState) -> Result<Router, NodeError>;Source line: 206.