| Crates.io | yellowstone-shield-store |
| lib.rs | yellowstone-shield-store |
| version | 0.6.0 |
| created_at | 2025-03-28 13:26:25.095752+00 |
| updated_at | 2025-07-16 16:27:28.807944+00 |
| description | Policy store for the Yellowstone Shield program |
| homepage | |
| repository | https://github.com/rpcpool/yellowstone-shield |
| max_upload_size | |
| id | 1609595 |
| size | 239,125 |
The Policy Store is a library for managing and caching validator policies for Yellowstone Shield. It provides caching, snapshot updates, and validator permission lookups.
ArcSwap for updating policy snapshots without locking reads.To integrate and use the Policy Store in Rust applications:
cargo add yellowstone-shield-store
use solana_sdk::pubkey::Pubkey;
use yellowstone_shield_store::{PolicyStore, PolicyStoreConfig, PolicyStoreTrait};
#[derive(Parser)]
struct Opts {
#[clap(short, long)]
config: String,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let Opts { config } = Opts::parse();
let config = std::fs::read_to_string(config).expect("Error reading config file");
let config: PolicyStoreConfig = toml::from_str(&config).expect("Error parsing config");
let local = tokio::task::LocalSet::new();
let policy_store = PolicyStore::build()
.config(config)
.run(&local)
.await?;
local
.run_until(async {
// Retrieve the latest snapshot of validator policies
let snapshot = policy_store.snapshot();
// Define validator and policy pubkeys to check permission
// Note: These are dummy pubkeys for demonstration purposes
let validator = Pubkey::new_unique();
let policy = Pubkey::new_unique();
// Check if the validator is allowed by the policy
match snapshot.is_allowed(&[policy], &validator) {
Ok(true) => println!("Validator is allowed."),
Ok(false) => println!("Validator is denied."),
Err(e) => println!("Error checking policy: {:?}", e),
}
Ok(())
})
.await
}
Ensure you have Rust installed, then use:
cargo build
cargo test
Licensed under AGPL-3.0.