pub struct ColdStorage<B = ErasedBackend>where
B: ColdStorageBackend,{ /* private fields */ }Expand description
Unified handle for interacting with a cold storage backend.
ColdStorage<B> is cheap to Clone — it is just an Arc around the
shared inner state. All operations dispatch through semaphore-gated
TaskTracker-spawned tasks.
Implementations§
Source§impl<B> ColdStorage<B>where
B: ColdStorageBackend,
impl<B> ColdStorage<B>where
B: ColdStorageBackend,
Sourcepub fn new(backend: B, cancel: CancellationToken) -> ColdStorage<B>
pub fn new(backend: B, cancel: CancellationToken) -> ColdStorage<B>
Create a new cold storage handle wrapping backend.
A hidden coordinator task watches cancel and, on fire, closes the
read/write/stream semaphores and the task tracker. After cancel,
all handle methods fail fast with ColdStorageError::TaskTerminated
on permit acquisition; in-flight spawned tasks drain to completion
bounded by backend timeouts.
Sourcepub async fn wait_shutdown(&self)
pub async fn wait_shutdown(&self)
Close the task tracker and wait for all in-flight tasks to finish.
Idempotent with the shutdown coordinator: safe to call whether or not the cancel token has fired.
Sourcepub async fn get_header(
&self,
spec: HeaderSpecifier,
) -> Result<Option<Sealed<Header>>, ColdStorageError>
pub async fn get_header( &self, spec: HeaderSpecifier, ) -> Result<Option<Sealed<Header>>, ColdStorageError>
Get a header by specifier.
Sourcepub async fn get_header_by_number(
&self,
block: u64,
) -> Result<Option<Sealed<Header>>, ColdStorageError>
pub async fn get_header_by_number( &self, block: u64, ) -> Result<Option<Sealed<Header>>, ColdStorageError>
Get a header by block number.
Sourcepub async fn get_header_by_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<Sealed<Header>>, ColdStorageError>
pub async fn get_header_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Sealed<Header>>, ColdStorageError>
Get a header by block hash.
Sourcepub async fn get_headers(
&self,
specs: Vec<HeaderSpecifier>,
) -> Result<Vec<Option<Sealed<Header>>>, ColdStorageError>
pub async fn get_headers( &self, specs: Vec<HeaderSpecifier>, ) -> Result<Vec<Option<Sealed<Header>>>, ColdStorageError>
Get multiple headers by specifiers.
Sourcepub async fn get_transaction(
&self,
spec: TransactionSpecifier,
) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
pub async fn get_transaction( &self, spec: TransactionSpecifier, ) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
Get a transaction by specifier, with block confirmation metadata.
Sourcepub async fn get_tx_by_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
pub async fn get_tx_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
Get a transaction by hash.
Sourcepub async fn get_tx_by_block_and_index(
&self,
block: u64,
index: u64,
) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
pub async fn get_tx_by_block_and_index( &self, block: u64, index: u64, ) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
Get a transaction by block number and index.
Sourcepub async fn get_tx_by_block_hash_and_index(
&self,
block_hash: FixedBytes<32>,
index: u64,
) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
pub async fn get_tx_by_block_hash_and_index( &self, block_hash: FixedBytes<32>, index: u64, ) -> Result<Option<Confirmed<Recovered<EthereumTxEnvelope<TxEip4844>>>>, ColdStorageError>
Get a transaction by block hash and index.
Sourcepub async fn get_transactions_in_block(
&self,
block: u64,
) -> Result<Vec<Recovered<EthereumTxEnvelope<TxEip4844>>>, ColdStorageError>
pub async fn get_transactions_in_block( &self, block: u64, ) -> Result<Vec<Recovered<EthereumTxEnvelope<TxEip4844>>>, ColdStorageError>
Get all transactions in a block.
Sourcepub async fn get_transaction_count(
&self,
block: u64,
) -> Result<u64, ColdStorageError>
pub async fn get_transaction_count( &self, block: u64, ) -> Result<u64, ColdStorageError>
Get the transaction count for a block.
Sourcepub async fn get_receipt(
&self,
spec: ReceiptSpecifier,
) -> Result<Option<ColdReceipt>, ColdStorageError>
pub async fn get_receipt( &self, spec: ReceiptSpecifier, ) -> Result<Option<ColdReceipt>, ColdStorageError>
Get a receipt by specifier.
Sourcepub async fn get_receipt_by_tx_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<ColdReceipt>, ColdStorageError>
pub async fn get_receipt_by_tx_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<ColdReceipt>, ColdStorageError>
Get a receipt by transaction hash.
Sourcepub async fn get_receipt_by_block_and_index(
&self,
block: u64,
index: u64,
) -> Result<Option<ColdReceipt>, ColdStorageError>
pub async fn get_receipt_by_block_and_index( &self, block: u64, index: u64, ) -> Result<Option<ColdReceipt>, ColdStorageError>
Get a receipt by block number and index.
Sourcepub async fn get_receipts_in_block(
&self,
block: u64,
) -> Result<Vec<ColdReceipt>, ColdStorageError>
pub async fn get_receipts_in_block( &self, block: u64, ) -> Result<Vec<ColdReceipt>, ColdStorageError>
Get all receipts in a block.
Sourcepub async fn get_signet_events(
&self,
spec: SignetEventsSpecifier,
) -> Result<Vec<DbSignetEvent>, ColdStorageError>
pub async fn get_signet_events( &self, spec: SignetEventsSpecifier, ) -> Result<Vec<DbSignetEvent>, ColdStorageError>
Get signet events by specifier.
Sourcepub async fn get_signet_events_in_block(
&self,
block: u64,
) -> Result<Vec<DbSignetEvent>, ColdStorageError>
pub async fn get_signet_events_in_block( &self, block: u64, ) -> Result<Vec<DbSignetEvent>, ColdStorageError>
Get signet events in a block.
Sourcepub async fn get_signet_events_in_range(
&self,
start: u64,
end: u64,
) -> Result<Vec<DbSignetEvent>, ColdStorageError>
pub async fn get_signet_events_in_range( &self, start: u64, end: u64, ) -> Result<Vec<DbSignetEvent>, ColdStorageError>
Get signet events in a range of blocks.
Sourcepub async fn get_zenith_header(
&self,
block: u64,
) -> Result<Option<DbZenithHeader>, ColdStorageError>
pub async fn get_zenith_header( &self, block: u64, ) -> Result<Option<DbZenithHeader>, ColdStorageError>
Get a zenith header by block number.
Sourcepub async fn get_zenith_headers(
&self,
spec: ZenithHeaderSpecifier,
) -> Result<Vec<DbZenithHeader>, ColdStorageError>
pub async fn get_zenith_headers( &self, spec: ZenithHeaderSpecifier, ) -> Result<Vec<DbZenithHeader>, ColdStorageError>
Get zenith headers by specifier.
Sourcepub async fn get_zenith_headers_in_range(
&self,
start: u64,
end: u64,
) -> Result<Vec<DbZenithHeader>, ColdStorageError>
pub async fn get_zenith_headers_in_range( &self, start: u64, end: u64, ) -> Result<Vec<DbZenithHeader>, ColdStorageError>
Get zenith headers in a range of blocks.
Sourcepub async fn get_logs(
&self,
filter: Filter,
max_logs: usize,
) -> Result<Vec<Log>, ColdStorageError>
pub async fn get_logs( &self, filter: Filter, max_logs: usize, ) -> Result<Vec<Log>, ColdStorageError>
Filter logs by block range, address, and topics.
Follows eth_getLogs semantics. Returns matching logs ordered by
(block_number, tx_index, log_index).
Sourcepub async fn stream_logs(
&self,
filter: Filter,
max_logs: usize,
deadline: Duration,
) -> Result<ReceiverStream<Result<Log, ColdStorageError>>, ColdStorageError>
pub async fn stream_logs( &self, filter: Filter, max_logs: usize, deadline: Duration, ) -> Result<ReceiverStream<Result<Log, ColdStorageError>>, ColdStorageError>
Stream logs matching a filter.
Returns a LogStream that yields matching logs in order.
Consume with StreamExt::next() until None. If the last item is
Err(...), an error occurred (deadline, too many logs, reorg).
The deadline is clamped to the handle’s configured maximum.
Sourcepub async fn get_latest_block(&self) -> Result<Option<u64>, ColdStorageError>
pub async fn get_latest_block(&self) -> Result<Option<u64>, ColdStorageError>
Get the latest block number in storage.
Sourcepub async fn append_block(
&self,
data: BlockData,
) -> Result<(), ColdStorageError>
pub async fn append_block( &self, data: BlockData, ) -> Result<(), ColdStorageError>
Append a single block to cold storage.
Sourcepub async fn append_blocks(
&self,
data: Vec<BlockData>,
) -> Result<(), ColdStorageError>
pub async fn append_blocks( &self, data: Vec<BlockData>, ) -> Result<(), ColdStorageError>
Append multiple blocks to cold storage.
Sourcepub async fn truncate_above(&self, block: u64) -> Result<(), ColdStorageError>
pub async fn truncate_above(&self, block: u64) -> Result<(), ColdStorageError>
Truncate all data above the given block number.
This removes block N+1 and higher from all tables and invalidates any
cached lookups above block.
Sourcepub async fn drain_above(
&self,
block: u64,
) -> Result<Vec<Vec<ColdReceipt>>, ColdStorageError>
pub async fn drain_above( &self, block: u64, ) -> Result<Vec<Vec<ColdReceipt>>, ColdStorageError>
Read and remove all blocks above the given block number.
Returns receipts for each block above block in ascending order,
then truncates. Index 0 = block+1, index 1 = block+2, etc.
Source§impl ColdStorage
impl ColdStorage
Sourcepub fn new_erased<B>(backend: B, cancel: CancellationToken) -> ColdStoragewhere
B: ColdStorageBackend,
pub fn new_erased<B>(backend: B, cancel: CancellationToken) -> ColdStoragewhere
B: ColdStorageBackend,
Construct a type-erased cold storage handle.
Wraps backend in ErasedBackend so the resulting handle
has no B type parameter to propagate through downstream
signatures. Equivalent to
ColdStorage::new(ErasedBackend::new(backend), cancel).
Choose this constructor when you want runtime swappability of
the backend; use new directly for fully
monomorphized call sites.
Trait Implementations§
Source§impl<B> Clone for ColdStorage<B>where
B: ColdStorageBackend,
impl<B> Clone for ColdStorage<B>where
B: ColdStorageBackend,
Source§fn clone(&self) -> ColdStorage<B>
fn clone(&self) -> ColdStorage<B>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<B> Freeze for ColdStorage<B>
impl<B = ErasedBackend> !RefUnwindSafe for ColdStorage<B>
impl<B> Send for ColdStorage<B>
impl<B> Sync for ColdStorage<B>
impl<B> Unpin for ColdStorage<B>
impl<B> UnsafeUnpin for ColdStorage<B>
impl<B = ErasedBackend> !UnwindSafe for ColdStorage<B>
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§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.