Skip to main content

Crate solana_infra_doctor

Crate solana_infra_doctor 

Source
Expand description

Solana Infra Doctor — the reusable diagnostic engine.

This crate provides the Solana RPC production-readiness diagnostics that the sol-doctor binary exposes on the command line. The binary is a thin frontend; all diagnostic logic lives here so it can be embedded in other interfaces (for example a CI wrapper) without the CLI.

The engine is intentionally lightweight: raw HTTP JSON-RPC via reqwest and WebSocket diagnostics via tokio-tungstenite, with no Solana SDK dependency.

§Layout

  • checks — single-endpoint HTTP JSON-RPC diagnostics and verdicts.
  • compare — multi-endpoint comparison, scoring, and report rendering.
  • ws — WebSocket (slotSubscribe) readiness diagnostics.
  • grpc — Yellowstone gRPC readiness diagnostics (connect, optional x-token auth, unary probes, and a slot-only Subscribe stream).
  • rpc — the JSON-RPC client, endpoint parsing, and wire models.
  • redact — credential/API-key redaction for safe output.
  • report, latency, verdict, error — output and shared models.
  • output — shared human-terminal presentation helpers (status vocabulary, unit formatting, tables); not used by JSON or Markdown output.
  • color — TTY-aware ANSI styling for human output.
  • cli — argument types shared with the binary frontend.

§Primary entrypoints

use solana_infra_doctor::{cli::CheckArgs, run_check};

let report = run_check(CheckArgs {
    rpc: "https://api.mainnet-beta.solana.com".to_string(),
    json: false,
    fail_on_warning: false,
    samples: 1,
    data: false,
    data_program: None,
    timeout_ms: 5_000,
})
.await?;
println!("{}", report.verdict);

Re-exports§

pub use checks::run_check;
pub use compare::run_compare;
pub use grpc::run_grpc_check;
pub use redact::redact_text;
pub use redact::redact_url;
pub use ws::run_ws;

Modules§

checks
Single-endpoint HTTP JSON-RPC readiness diagnostics: run the core, blockhash, and performance checks against one RPC endpoint and produce a CheckReport.
cli
Command-line argument types, shared between the sol-doctor binary and the library so an embedding frontend can construct the same inputs.
color
Cohesive, dependency-free ANSI styling for human terminal output.
compare
Multi-endpoint comparison: run the per-endpoint checks, score each endpoint for a workload profile, rank them, and produce a CompareReport. Rendering lives in render and scoring in scoring.
error
The crate’s error type. All fallible engine functions return AppError; the library never exits the process.
grpc
Yellowstone gRPC readiness diagnostics: connect, optionally authenticate with an x-token, run safe unary probes, open a narrow slot-only Subscribe stream, and (optionally) cross-check the latest observed slot against an HTTP RPC endpoint.
latency
A simple millisecond latency measurement and averaging helper.
output
Human-facing terminal output helpers.
redact
Centralized redaction for RPC URLs and any text that may embed them.
report
rpc
The HTTP JSON-RPC client, endpoint parsing/validation, and wire models. URLs are treated as secret-bearing: they are redacted before appearing in any output, Debug, or error.
verdict
The overall readiness verdict shared by every command, and its mapping to a process exit code.
ws
WebSocket readiness diagnostics: connect, subscribe (slotSubscribe by default, see subscription), measure time-to-first-notification, unsubscribe, and close — with exponential-backoff reconnect on a dropped or failed connection.