pub struct ProgramCacheForTxBatch {
pub environments: ProgramRuntimeEnvironments,
pub upcoming_environments: Option<ProgramRuntimeEnvironments>,
pub latest_root_epoch: Epoch,
pub hit_max_limit: bool,
pub loaded_missing: bool,
pub merged_modified: bool,
/* private fields */
}Expand description
Local view into ProgramCache which was extracted for a specific TX batch.
This isolation enables the global ProgramCache to continue to evolve (e.g. evictions), while the TX batch is guaranteed it will continue to find all the programs it requires. For program management instructions this also buffers them before they are merged back into the global ProgramCache.
Fields§
§environments: ProgramRuntimeEnvironments§upcoming_environments: Option<ProgramRuntimeEnvironments>Anticipated replacement for environments at the next epoch.
This is None during most of an epoch, and only Some around the boundaries (at the end and beginning of an epoch).
More precisely, it starts with the cache preparation phase a few hundred slots before the epoch boundary,
and it ends with the first rerooting after the epoch boundary.
Needed when a program is deployed at the last slot of an epoch, becomes effective in the next epoch.
So needs to be compiled with the environment for the next epoch.
latest_root_epoch: EpochThe epoch of the last rerooting
hit_max_limit: bool§loaded_missing: bool§merged_modified: boolImplementations§
source§impl ProgramCacheForTxBatch
impl ProgramCacheForTxBatch
pub fn new( slot: Slot, environments: ProgramRuntimeEnvironments, upcoming_environments: Option<ProgramRuntimeEnvironments>, latest_root_epoch: Epoch, ) -> Self
pub fn new_from_cache<FG: ForkGraph>( slot: Slot, epoch: Epoch, cache: &ProgramCache<FG>, ) -> Self
sourcepub fn get_environments_for_epoch(
&self,
epoch: Epoch,
) -> &ProgramRuntimeEnvironments
pub fn get_environments_for_epoch( &self, epoch: Epoch, ) -> &ProgramRuntimeEnvironments
Returns the current environments depending on the given epoch
sourcepub fn replenish(
&mut self,
key: Pubkey,
entry: Arc<ProgramCacheEntry>,
) -> (bool, Arc<ProgramCacheEntry>)
pub fn replenish( &mut self, key: Pubkey, entry: Arc<ProgramCacheEntry>, ) -> (bool, Arc<ProgramCacheEntry>)
Refill the cache with a single entry. It’s typically called during transaction loading, and
transaction processing (for program management instructions).
It replaces the existing entry (if any) with the provided entry. The return value contains
true if an entry existed.
The function also returns the newly inserted value.
sourcepub fn store_modified_entry(
&mut self,
key: Pubkey,
entry: Arc<ProgramCacheEntry>,
)
pub fn store_modified_entry( &mut self, key: Pubkey, entry: Arc<ProgramCacheEntry>, )
Store an entry in modified_entries for a program modified during the
transaction batch.
sourcepub fn drain_modified_entries(
&mut self,
) -> HashMap<Pubkey, Arc<ProgramCacheEntry>>
pub fn drain_modified_entries( &mut self, ) -> HashMap<Pubkey, Arc<ProgramCacheEntry>>
Drain the program cache’s modified entries, returning the owned collection.
pub fn find(&self, key: &Pubkey) -> Option<Arc<ProgramCacheEntry>>
pub fn slot(&self) -> Slot
pub fn set_slot_for_tests(&mut self, slot: Slot)
pub fn merge( &mut self, modified_entries: &HashMap<Pubkey, Arc<ProgramCacheEntry>>, )
pub fn is_empty(&self) -> bool
Trait Implementations§
source§impl Clone for ProgramCacheForTxBatch
impl Clone for ProgramCacheForTxBatch
source§fn clone(&self) -> ProgramCacheForTxBatch
fn clone(&self) -> ProgramCacheForTxBatch
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ProgramCacheForTxBatch
impl Debug for ProgramCacheForTxBatch
source§impl Default for ProgramCacheForTxBatch
impl Default for ProgramCacheForTxBatch
source§fn default() -> ProgramCacheForTxBatch
fn default() -> ProgramCacheForTxBatch
Auto Trait Implementations§
impl Freeze for ProgramCacheForTxBatch
impl RefUnwindSafe for ProgramCacheForTxBatch
impl Send for ProgramCacheForTxBatch
impl Sync for ProgramCacheForTxBatch
impl Unpin for ProgramCacheForTxBatch
impl UnwindSafe for ProgramCacheForTxBatch
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more