pub struct BlockDataBuffer { /* private fields */ }Expand description
In-memory overlay for not-yet-flushed block data. Consulted before disk by every read of headers/bodies/numbers/receipts/codes/tx-locations.
Held behind Arc<RwLock<Arc<BlockDataBuffer>>> in Store. Readers clone
the inner Arc under a brief read lock and then work lock-free; the single
writer mutates a clone and RCU-swaps the Arc in. Both critical sections
are O(1) pointer operations.
Implementations§
Source§impl BlockDataBuffer
impl BlockDataBuffer
pub fn new() -> Self
Sourcepub fn insert(
&mut self,
block: Block,
receipts: Vec<Receipt>,
codes: Vec<(H256, Code)>,
)
pub fn insert( &mut self, block: Block, receipts: Vec<Receipt>, codes: Vec<(H256, Code)>, )
Takes ownership of block and moves its header/body into the buffer (the
caller hands ownership over the flush channel and drops it right after, so
cloning would be pure waste).
pub fn get_header(&self, hash: &BlockHash) -> Option<BlockHeader>
pub fn get_body(&self, hash: &BlockHash) -> Option<BlockBody>
pub fn get_number(&self, hash: &BlockHash) -> Option<BlockNumber>
pub fn get_receipt(&self, hash: &BlockHash, index: u64) -> Option<Receipt>
pub fn get_receipts(&self, hash: &BlockHash) -> Option<Vec<Receipt>>
pub fn get_code(&self, code_hash: &H256) -> Option<Code>
pub fn get_tx_locations( &self, tx_hash: &H256, ) -> Vec<(BlockNumber, BlockHash, u64)>
pub fn flushed_upto(&self) -> BlockNumber
pub fn set_flushed_upto(&mut self, n: BlockNumber)
Sourcepub fn flushable(&self) -> Vec<Arc<BufferedBlock>>
pub fn flushable(&self) -> Vec<Arc<BufferedBlock>>
All unflushed blocks, ascending by number (deterministic flush order).
Sourcepub fn codes_for(&self, hashes: &[BlockHash]) -> Vec<(H256, Code)>
pub fn codes_for(&self, hashes: &[BlockHash]) -> Vec<(H256, Code)>
Codes introduced by the given block hashes (for the flush write tx).
Sourcepub fn evict_flushed(&mut self, new_flushed_upto: BlockNumber)
pub fn evict_flushed(&mut self, new_flushed_upto: BlockNumber)
Drop all buffered data for blocks with number <= new_flushed_upto and
advance the durable marker. Called only after the disk write committed.
Trait Implementations§
Source§impl Clone for BlockDataBuffer
impl Clone for BlockDataBuffer
Source§fn clone(&self) -> BlockDataBuffer
fn clone(&self) -> BlockDataBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockDataBuffer
impl Debug for BlockDataBuffer
Auto Trait Implementations§
impl Freeze for BlockDataBuffer
impl RefUnwindSafe for BlockDataBuffer
impl Send for BlockDataBuffer
impl Sync for BlockDataBuffer
impl Unpin for BlockDataBuffer
impl UnsafeUnpin for BlockDataBuffer
impl UnwindSafe for BlockDataBuffer
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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§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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.