Skip to main content

AdminRpcClient

Trait AdminRpcClient 

Source
pub trait AdminRpcClient: ClientT {
    // Provided methods
    fn health(
        &self,
    ) -> impl Future<Output = Result<HealthResponse, Error>> + Send { ... }
    fn evict(
        &self,
        req: EvictRequest,
    ) -> impl Future<Output = Result<EvictResponse, Error>> + Send { ... }
    fn reload(
        &self,
    ) -> impl Future<Output = Result<ReloadResponse, Error>> + Send { ... }
    fn drain(
        &self,
        req: DrainRequest,
    ) -> impl Future<Output = Result<DrainResponse, Error>> + Send { ... }
    fn status(
        &self,
    ) -> impl Future<Output = Result<StatusResponse, Error>> + Send { ... }
    fn lanes(&self) -> impl Future<Output = Result<LanesResponse, Error>> + Send { ... }
    fn slashes(
        &self,
    ) -> impl Future<Output = Result<SlashesResponse, Error>> + Send { ... }
    fn pools(
        &self,
    ) -> impl Future<Output = Result<BuyerPoolsResponse, Error>> + Send { ... }
}
Expand description

Client implementation for the AdminRpc RPC API.

Provided Methods§

Source

fn health(&self) -> impl Future<Output = Result<HealthResponse, Error>> + Send

Return this node’s identity and process uptime.

Source

fn evict( &self, req: EvictRequest, ) -> impl Future<Output = Result<EvictResponse, Error>> + Send

Evict a single blob from the local cache (issue #279). The eviction is logical: the iroh-blobs store still holds the bytes (Blobs::delete is pub(crate) in iroh-blobs and reserved for the GC task) until the next periodic GC sweep reclaims them (#518). The takedown itself is persisted to <cache_dir>/evicted.log so it survives a restart even when the next sweep hasn’t run yet.

When req.dry_run is true (issue #379) the cache state is not mutated: the response carries the pre-evict snapshot (size, last-access elapsed time, pin status, already-evicted flag) so operators running DMCA takedowns can confirm what the real evict will touch before committing. The same response shape is used for the real-evict path with the snapshot reflecting the pre-mutation state.

Source

fn reload(&self) -> impl Future<Output = Result<ReloadResponse, Error>> + Send

Re-read the config file the node was started with and apply the reloadable subset (issue #373) — the same path SIGHUP triggers, exposed over the loopback admin surface for operators who want scripted control without kill -HUP. Both paths share the same RuntimeReloadState::reload, whose internal mutexes serialise concurrent reloads, so a SIGHUP racing this RPC waits behind it rather than corrupting state. Returns:

  • CONFIG_PATH_UNSET_CODE when the node was started without a config path (CLI-only flag invocation has nothing to re-read).
  • RELOAD_ERROR_CODE when the reload itself fails — previous values are retained, matching the SIGHUP behaviour.
  • On success: ReloadResponse carrying the post-reload log_level.
Source

fn drain( &self, req: DrainRequest, ) -> impl Future<Output = Result<DrainResponse, Error>> + Send

Trigger graceful shutdown via the same path SIGTERM exercises (issue #244, appendix-local-admin-http.md). Stops the iroh router’s accept loop and awaits in-flight ProtocolHandler::shutdown calls; the subsequent task drain is bounded by the runtime’s 15s SHUTDOWN_DEADLINE (the router-shutdown step itself is unbounded — a stuck handler hangs the runtime, only the post-router task join is timeout-gated).

Fire-and-forget by default: the response returns as soon as the trigger lands, not when shutdown completes. Equivalent to kill -TERM <pid> for operators who’d rather not stat the PID.

The DrainRequest parameter is required. wait_admin: false gets the SIGTERM-equivalent shutdown order. wait_admin: true (issue #604) asks the runtime to keep the admin server alive through router.shutdown so a polling client can observe admin_v1_health.in_flight_streams reach 0.

Source

fn status(&self) -> impl Future<Output = Result<StatusResponse, Error>> + Send

Return a snapshot of this node’s DHT participation health (issue #741): routing-table bucket fill rates, the network-wide last bucket-refresh timestamp, active-staker count, provider-record store utilization, and republish-scheduler depth. Intended for decdn node status, giving operators a single human-readable (or --json) view to diagnose cold-start or routing-table degradation without scraping Prometheus. Returns DHT_UNAVAILABLE_CODE when the DHT subsystem is not wired on this node.

Source

fn lanes(&self) -> impl Future<Output = Result<LanesResponse, Error>> + Send

Return a live snapshot of every lane this node provides against a PaymentPool (issue #749): per lane the outstanding accrued claim, time since the last voucher (in-memory, None after a restart until the next voucher), and whether the accrued claim has reached the redemption threshold. Backs decdn node lanes, giving operators a single view to spot lanes approaching settlement, stale lanes, or unusually high outstanding balances before they become a liquidity risk — without scraping metrics or logs. Returns POOL_STORE_ERROR_CODE if the pool state store cannot be read.

Source

fn slashes(&self) -> impl Future<Output = Result<SlashesResponse, Error>> + Send

Return every slash the node’s watcher has detected against its own operator (#1032, G-NODE-05): per slash the slashId, offense type, amount, evidence digest, block, and the 30-day appeal-window close time. Consumed directly by operators/keepers (no CLI subcommand wraps it) so they notice a slash and file decdn appeal slash in time. Returns SLASH_DETECTION_UNAVAILABLE_CODE when the slash watcher is not wired on this node.

Source

fn pools( &self, ) -> impl Future<Output = Result<BuyerPoolsResponse, Error>> + Send

Return the node’s buyer-side PaymentPool state: every pool its buyer leg tracks, the deposit it believes each holds, and the per-lane spend watermark it has signed against each provider.

This is the buyer-side counterpart of Self::lanes, and the only read path to buyer.redb on a running node — redb holds a process-exclusive lock on that file for the daemon’s lifetime, so a CLI pointed at the daemon’s data dir cannot open it and would otherwise report an unrelated empty store as the node’s state.

Returns BUYER_POOL_UNAVAILABLE_CODE when no buyer leg is wired, and BUYER_POOL_STORE_ERROR_CODE when the store cannot be read.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<TypeJsonRpseeInternal> AdminRpcClient for TypeJsonRpseeInternal
where TypeJsonRpseeInternal: ClientT,