pub struct PrioritizationFeeCache {
cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>,
service_thread: Option<JoinHandle<()>>,
sender: Sender<CacheServiceUpdate>,
metrics: Arc<PrioritizationFeeCacheMetrics>,
}
Expand description
Stores up to MAX_NUM_RECENT_BLOCKS recent block’s prioritization fee,
A separate internal thread service_thread
handles additional tasks when a bank is frozen,
and collecting stats and reporting metrics.
Fields§
§cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>
§service_thread: Option<JoinHandle<()>>
§sender: Sender<CacheServiceUpdate>
§metrics: Arc<PrioritizationFeeCacheMetrics>
Implementations§
source§impl PrioritizationFeeCache
impl PrioritizationFeeCache
pub fn new(capacity: u64) -> Self
sourcefn get_prioritization_fee(
cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>,
slot: &Slot
) -> Arc<Mutex<PrioritizationFee>>
fn get_prioritization_fee( cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>, slot: &Slot ) -> Arc<Mutex<PrioritizationFee>>
Get prioritization fee entry, create new entry if necessary
sourcepub fn update<'a>(
&self,
bank: &Bank,
txs: impl Iterator<Item = &'a SanitizedTransaction>
)
pub fn update<'a>( &self, bank: &Bank, txs: impl Iterator<Item = &'a SanitizedTransaction> )
Update with a list of non-vote transactions’ tx_priority_details and tx_account_locks; Only transactions have both valid priority_detail and account_locks will be used to update fee_cache asynchronously.
sourcepub fn finalize_priority_fee(&self, slot: Slot)
pub fn finalize_priority_fee(&self, slot: Slot)
Finalize prioritization fee when it’s bank is completely replayed from blockstore, by pruning irrelevant accounts to save space, and marking its availability for queries.
sourcefn update_cache(
cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>,
slot: &Slot,
transaction_fee: u64,
writable_accounts: Arc<Vec<Pubkey>>,
metrics: Arc<PrioritizationFeeCacheMetrics>
)
fn update_cache( cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>, slot: &Slot, transaction_fee: u64, writable_accounts: Arc<Vec<Pubkey>>, metrics: Arc<PrioritizationFeeCacheMetrics> )
Internal function is invoked by worker thread to update slot’s minimum prioritization fee, Cache lock contends here.
fn finalize_slot( cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>, slot: &Slot, metrics: Arc<PrioritizationFeeCacheMetrics> )
fn service_loop( cache: Arc<RwLock<LruCache<Slot, Arc<Mutex<PrioritizationFee>>>>>, receiver: Receiver<CacheServiceUpdate>, metrics: Arc<PrioritizationFeeCacheMetrics> )
sourcepub fn available_block_count(&self) -> usize
pub fn available_block_count(&self) -> usize
Returns number of blocks that have finalized minimum fees collection