pub struct State {
pub db: Arc<RwLock<Box<dyn Database + Send + Sync>>>,
pub verified_blocks: Arc<RwLock<HashMap<Id, Block>>>,
}
Expand description
Manages block and chain states for this Vm, both in-memory and persistent.
Fields§
§db: Arc<RwLock<Box<dyn Database + Send + Sync>>>
§verified_blocks: Arc<RwLock<HashMap<Id, Block>>>
Maps block Id to Block. Each element is verified but not yet accepted/rejected (e.g., preferred).
Implementations§
Source§impl State
impl State
Sourcepub async fn set_last_accepted_block(&self, blk_id: &Id) -> Result<()>
pub async fn set_last_accepted_block(&self, blk_id: &Id) -> Result<()>
Sourcepub async fn has_last_accepted_block(&self) -> Result<bool>
pub async fn has_last_accepted_block(&self) -> Result<bool>
Sourcepub async fn get_last_accepted_block_id(&self) -> Result<Id>
pub async fn get_last_accepted_block_id(&self) -> Result<Id>
Sourcepub async fn add_verified(&mut self, block: &Block)
pub async fn add_verified(&mut self, block: &Block)
Adds a block to “verified_blocks
”.
Sourcepub async fn remove_verified(&mut self, blk_id: &Id)
pub async fn remove_verified(&mut self, blk_id: &Id)
Removes a block from “verified_blocks
”.
Sourcepub async fn has_verified(&self, blk_id: &Id) -> bool
pub async fn has_verified(&self, blk_id: &Id) -> bool
Returns “true” if the block Id has been already verified.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl !RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl !UnwindSafe for State
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request