kora_lib/usage_limit/limiter.rs
1use solana_sdk::pubkey::Pubkey;
2
3use crate::transaction::VersionedTransactionResolved;
4
5/// Context passed to all limiters containing transaction data and resolved user identifier
6pub struct LimiterContext<'a> {
7 /// The resolved transaction
8 pub transaction: &'a mut VersionedTransactionResolved,
9 /// User identifier for usage tracking (can be any string - pubkey, UUID, etc.)
10 pub user_id: String,
11 /// Kora signer pubkey (if present) - used for filtering applicable instructions
12 pub kora_signer: Option<Pubkey>,
13 /// Unix timestamp of the request
14 pub timestamp: u64,
15}
16
17/// Result of a limiter check
18#[derive(Debug, Clone)]
19pub enum LimiterResult {
20 /// Transaction allowed
21 Allowed,
22 /// Transaction denied with reason
23 Denied { reason: String },
24}