Skip to main content

ImageCache

Struct ImageCache 

Source
pub struct ImageCache { /* private fields */ }
Expand description

Map from Image::content_hash to a parsed PvmProgram. The PvmProgram is wrapped in Arc so the same predecoded body can be referenced from multiple in-flight InstanceEntries (siblings) and from concurrent threads (the kernel may eventually be multi-threaded).

Implementations§

Source§

impl ImageCache

Source

pub fn new() -> Self

Source

pub fn len(&self) -> usize

Number of cached images.

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, content_hash: &CapHash) -> Option<Arc<PvmProgram>>

Look up by content hash. None if not yet cached.

Source

pub fn insert(&mut self, content_hash: CapHash, program: Arc<PvmProgram>)

Cache a precomputed program under the given content hash.

Source

pub fn get_or_decode( &mut self, content_hash: CapHash, code: Vec<u8>, bitmask: Vec<u8>, jump_table: Vec<u32>, ) -> Result<Arc<PvmProgram>, VmError>

Look up or compute: if the image’s content_hash is in the cache, return the cached program; otherwise parse code, bitmask, jump_table into a PvmProgram, cache it, and return it.

Source

pub fn clear(&mut self)

Drop all cached programs. Used at block boundaries by the chain orchestrator if it wants to free memory.

Trait Implementations§

Source§

impl Debug for ImageCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ImageCache

Source§

fn default() -> ImageCache

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.