solana leader
solana leader library
use
- default crate surface is the core only.
- use
LeaderEnginewith your own slot source and schedule snapshot. - call
seedwith the first live slot. - call
on_slotfor each new slot. - if a refresh is needed, fetch a new schedule snapshot and call
replace_schedule. - read the current leaders from the shared buffer.
features
- default features are empty
- core types are always available without extra features
rpcaddssolana_leader::rpc::ScheduleFetcherslotaddssolana_leader::slot::SlotSubscriberslot-grpcadds grpc slot support and impliesslotandrpcmanagedaddssolana_leader::managed::{ManagedTrackerConfig, ManagedTracker}and impliesrpc,slot, andslot-grpc
feature gates
- core only:
cargo add solana-leader - core with rpc fetch:
cargo add solana-leader --features rpc - core with slot subscription:
cargo add solana-leader --features slot - core with grpc slot subscription:
cargo add solana-leader --features slot-grpc - full managed tracker over websocket or grpc:
cargo add solana-leader --features managed
cargo.toml
[]
= "x.x.x"
[]
= { = "x.x.x", = ["rpc"] }
[]
= { = "x.x.x", = ["slot"] }
modules
solana_leadercore types and enginesolana_leader::rpccold-path schedule fetchsolana_leader::slotslot sources and connection handlingsolana_leader::managedfull tracker orchestration
api
- core:
LeaderEngine,EngineEvent,LeaderBuffer,LeaderEntry,LeaderPubkey,ScheduleSnapshot - rpc:
ScheduleFetcher,FetcherError - slot:
SlotSubscriber,SlotSubscriberError,SlotSourceConfig - slot grpc:
GrpcCommitment - managed:
ManagedTrackerConfig,ManagedTracker
limits
rpcsupportshttp://andhttps://- websocket slot subscription supports
ws://andwss:// - tls uses
rustlswith native system roots and stays on the cold path manageduses synchronous i/o plus std threads for the cold pathmanagedand the examples use spin-based polling on the fast path, so pin or isolate a core if you care about tail latency- the low-latency hot path stays in
LeaderEngineandLeaderBuffer
examples
cargo run --example example --features managed -- [slot_url] [rpc_url] [--ahead N]cargo run --example example_tokio --features managed -- [slot_url] [rpc_url]cargo run --example slot_subscriber --features slotcargo run --example example_grpc --features slot-grpc -- [grpc_url] [rpc_url]