solana-leader 0.4.0

solana leader library
Documentation

solana leader

solana leader library

use

  • default crate surface is the core only.
  • use LeaderEngine with your own slot source and schedule snapshot.
  • call seed with the first live slot.
  • call on_slot for 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
  • rpc adds solana_leader::rpc::ScheduleFetcher
  • slot adds solana_leader::slot::SlotSubscriber
  • slot-grpc adds grpc slot support and implies slot and rpc
  • managed adds solana_leader::managed::{ManagedTrackerConfig, ManagedTracker} and implies rpc, slot, and slot-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

[dependencies]
solana-leader = "x.x.x"
[dependencies]
solana-leader = { version = "x.x.x", features = ["rpc"] }
[dependencies]
solana-leader = { version = "x.x.x", features = ["slot"] }

modules

  • solana_leader core types and engine
  • solana_leader::rpc cold-path schedule fetch
  • solana_leader::slot slot sources and connection handling
  • solana_leader::managed full tracker orchestration

api

  • core: LeaderEngine, EngineEvent, LeaderBuffer, LeaderEntry, LeaderPubkey, ScheduleSnapshot
  • rpc: ScheduleFetcher, FetcherError
  • slot: SlotSubscriber, SlotSubscriberError, SlotSourceConfig
  • slot grpc: GrpcCommitment
  • managed: ManagedTrackerConfig, ManagedTracker

limits

  • rpc supports http:// and https://
  • websocket slot subscription supports ws:// and wss://
  • tls uses rustls with native system roots and stays on the cold path
  • managed uses synchronous i/o plus std threads for the cold path
  • managed and 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 LeaderEngine and LeaderBuffer

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 slot
  • cargo run --example example_grpc --features slot-grpc -- [grpc_url] [rpc_url]