Struct massa_storage::Storage
source · pub struct Storage {
pub(crate) blocks: Arc<RwLock<BlockIndexes>>,
pub(crate) operations: Arc<RwLock<OperationIndexes>>,
pub(crate) endorsements: Arc<RwLock<EndorsementIndexes>>,
pub(crate) block_owners: Arc<RwLock<PreHashMap<BlockId, usize>>>,
pub(crate) operation_owners: Arc<RwLock<PreHashMap<OperationId, usize>>>,
pub(crate) endorsement_owners: Arc<RwLock<PreHashMap<EndorsementId, usize>>>,
pub(crate) local_used_blocks: PreHashSet<BlockId>,
pub(crate) local_used_ops: PreHashSet<OperationId>,
pub(crate) local_used_endorsements: PreHashSet<EndorsementId>,
}
Expand description
A storage system for objects (blocks, operations…), shared by various components.
Fields§
§blocks: Arc<RwLock<BlockIndexes>>
global block storage
operations: Arc<RwLock<OperationIndexes>>
global operation storage
endorsements: Arc<RwLock<EndorsementIndexes>>
global operation storage
block_owners: Arc<RwLock<PreHashMap<BlockId, usize>>>
global block reference counter
operation_owners: Arc<RwLock<PreHashMap<OperationId, usize>>>
global operation reference counter
endorsement_owners: Arc<RwLock<PreHashMap<EndorsementId, usize>>>
global endorsement reference counter
local_used_blocks: PreHashSet<BlockId>
locally used block references
local_used_ops: PreHashSet<OperationId>
locally used operation references
local_used_endorsements: PreHashSet<EndorsementId>
locally used endorsement references
Implementations§
source§impl Storage
impl Storage
sourcepub fn create_root() -> Storage
pub fn create_root() -> Storage
Creates a new Storage
instance. Must be called only one time in the execution:
- In the main for the node
- At the top of the test in tests
All others instances of Storage must be cloned from this one using clone()
or clone_without_refs()
.
sourcepub fn clone_without_refs(&self) -> Self
pub fn clone_without_refs(&self) -> Self
Clones the object to a new one that has no references
sourcepub fn extend(&mut self, other: Storage)
pub fn extend(&mut self, other: Storage)
Efficiently extends the current Storage by consuming the refs of another storage.
sourcepub fn split_off(
&mut self,
blocks: &PreHashSet<BlockId>,
operations: &PreHashSet<OperationId>,
endorsements: &PreHashSet<EndorsementId>,
) -> Storage
pub fn split_off( &mut self, blocks: &PreHashSet<BlockId>, operations: &PreHashSet<OperationId>, endorsements: &PreHashSet<EndorsementId>, ) -> Storage
Efficiently splits off a subset of the reference ownership into a new Storage object. Panics if some of the refs are not owned by the source.
sourcepub(crate) fn internal_claim_refs<IdT: Id + PartialEq + Eq + Hash + PreHashed + Copy>(
ids: &PreHashSet<IdT>,
owners: &mut RwLockWriteGuard<'_, PreHashMap<IdT, usize>>,
local_used_ids: &mut PreHashSet<IdT>,
)
pub(crate) fn internal_claim_refs<IdT: Id + PartialEq + Eq + Hash + PreHashed + Copy>( ids: &PreHashSet<IdT>, owners: &mut RwLockWriteGuard<'_, PreHashMap<IdT, usize>>, local_used_ids: &mut PreHashSet<IdT>, )
internal helper to locally claim a reference to an object
sourcepub fn get_block_refs(&self) -> &PreHashSet<BlockId>
pub fn get_block_refs(&self) -> &PreHashSet<BlockId>
get the block reference ownership
sourcepub fn claim_block_refs(
&mut self,
ids: &PreHashSet<BlockId>,
) -> PreHashSet<BlockId>
pub fn claim_block_refs( &mut self, ids: &PreHashSet<BlockId>, ) -> PreHashSet<BlockId>
Claim block references. Returns the set of block refs that were found and claimed.
sourcepub fn drop_block_refs(&mut self, ids: &PreHashSet<BlockId>)
pub fn drop_block_refs(&mut self, ids: &PreHashSet<BlockId>)
Drop block references
sourcepub fn store_block(&mut self, block: SecureShareBlock)
pub fn store_block(&mut self, block: SecureShareBlock)
Store a block Note that this also claims a local reference to the block
sourcepub fn claim_operation_refs(
&mut self,
ids: &PreHashSet<OperationId>,
) -> PreHashSet<OperationId>
pub fn claim_operation_refs( &mut self, ids: &PreHashSet<OperationId>, ) -> PreHashSet<OperationId>
Claim operation references. Returns the set of operation refs that were found and claimed.
sourcepub fn get_op_refs(&self) -> &PreHashSet<OperationId>
pub fn get_op_refs(&self) -> &PreHashSet<OperationId>
get the operation reference ownership
sourcepub fn drop_operation_refs(&mut self, ids: &PreHashSet<OperationId>)
pub fn drop_operation_refs(&mut self, ids: &PreHashSet<OperationId>)
Drop local operation references. Ignores already-absent refs.
sourcepub fn store_operations(&mut self, operations: Vec<SecureShareOperation>)
pub fn store_operations(&mut self, operations: Vec<SecureShareOperation>)
Store operations Claims a local reference to the added operation
sourcepub fn read_operations(&self) -> RwLockReadGuard<'_, OperationIndexes>
pub fn read_operations(&self) -> RwLockReadGuard<'_, OperationIndexes>
Gets a read reference to the operations index
sourcepub fn read_endorsements(&self) -> RwLockReadGuard<'_, EndorsementIndexes>
pub fn read_endorsements(&self) -> RwLockReadGuard<'_, EndorsementIndexes>
Gets a read reference to the endorsements index
sourcepub fn read_blocks(&self) -> RwLockReadGuard<'_, BlockIndexes>
pub fn read_blocks(&self) -> RwLockReadGuard<'_, BlockIndexes>
Gets a read reference to the blocks index
sourcepub fn claim_endorsement_refs(
&mut self,
ids: &PreHashSet<EndorsementId>,
) -> PreHashSet<EndorsementId>
pub fn claim_endorsement_refs( &mut self, ids: &PreHashSet<EndorsementId>, ) -> PreHashSet<EndorsementId>
Claim endorsement references. Returns the set of operation refs that were found and claimed.
sourcepub fn get_endorsement_refs(&self) -> &PreHashSet<EndorsementId>
pub fn get_endorsement_refs(&self) -> &PreHashSet<EndorsementId>
get the endorsement reference ownership
sourcepub fn drop_endorsement_refs(&mut self, ids: &PreHashSet<EndorsementId>)
pub fn drop_endorsement_refs(&mut self, ids: &PreHashSet<EndorsementId>)
Drop local endorsement references. Ignores already-absent refs.
sourcepub fn store_endorsements(&mut self, endorsements: Vec<SecureShareEndorsement>)
pub fn store_endorsements(&mut self, endorsements: Vec<SecureShareEndorsement>)
Store endorsements Claims local references to the added endorsements
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl !RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl !UnwindSafe for Storage
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.