pub struct InMemoryState<N: NodePrimitives = EthPrimitives> { /* private fields */ }Expand description
Container type for in memory state data of the executed blocks that are not on disk yet.
This tracks blocks and their state that haven’t been persisted to disk yet: the blocks that are part of the canonical chain that can be traced back to a canonical block on disk, and the executed blocks that are not canonical.
A node has one in-memory state. Clones are handles to the same blocks, pending block and metrics, and the default value is an empty state of its own.
§Locking behavior on state updates
Updates change the blocks, the numbers and the pending block under one write lock. This prevents readers from observing partially updated state where they are out of sync with each other, or a block that is both canonical and not canonical, or neither.
Implementations§
Source§impl<N: NodePrimitives> InMemoryState<N>
impl<N: NodePrimitives> InMemoryState<N>
Sourcepub fn state_by_hash(&self, hash: B256) -> Option<Arc<BlockState<N>>>
pub fn state_by_hash(&self, hash: B256) -> Option<Arc<BlockState<N>>>
Returns the state of the tracked block with the given hash, canonical or not.
Sourcepub fn contains(&self, hash: &B256) -> bool
pub fn contains(&self, hash: &B256) -> bool
Returns true if a block with the given hash is tracked, canonical or not.
Sourcepub fn block_counts(&self) -> InMemoryStateBlockCounts
pub fn block_counts(&self) -> InMemoryStateBlockCounts
Returns the numbers of tracked canonical blocks and of tracked blocks that are not canonical, both taken from the same snapshot of the blocks.
Sourcepub fn removal_generation(&self) -> u64
pub fn removal_generation(&self) -> u64
Returns a counter that increases every time blocks are removed.
State derived from the tracked blocks compares it with the value it saw last to learn that blocks it refers to may no longer be tracked.
Trait Implementations§
Source§impl<N: Clone + NodePrimitives> Clone for InMemoryState<N>
impl<N: Clone + NodePrimitives> Clone for InMemoryState<N>
Source§impl<N: Debug + NodePrimitives> Debug for InMemoryState<N>
impl<N: Debug + NodePrimitives> Debug for InMemoryState<N>
Auto Trait Implementations§
impl<N = EthPrimitives> !RefUnwindSafe for InMemoryState<N>
impl<N = EthPrimitives> !UnwindSafe for InMemoryState<N>
impl<N> Forget for InMemoryState<N>
impl<N> Freeze for InMemoryState<N>
impl<N> Move for InMemoryState<N>
impl<N> Send for InMemoryState<N>
impl<N> Sync for InMemoryState<N>
impl<N> Unpin for InMemoryState<N>
impl<N> UnsafeUnpin for InMemoryState<N>where
Arc<InMemoryStateInner<N>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreimpl<T> MaybeDebug for Twhere
T: Debug,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes