pub struct ColdStorageHandle { /* private fields */ }Expand description
Handle for interacting with the cold storage task.
This handle provides full access to both read and write operations. It can be cloned and shared across tasks.
§Channel Separation
Internally, this handle uses separate channels for reads and writes:
- Read channel: Shared with
ColdStorageReadHandle. Reads are processed concurrently (up to 64 in flight). - Write channel: Exclusive to this handle. Writes are processed sequentially to maintain ordering.
This design allows read-heavy workloads to proceed without being blocked by write operations, while ensuring write ordering is preserved.
§Read Access
All read methods from ColdStorageReadHandle are available on this
handle via Deref.
§Usage
let handle = ColdStorageTask::spawn(backend, cancel);
// Full access: reads and writes
handle.append_block(data).await?;
let header = handle.get_header_by_number(100).await?;
// Get a read-only handle for query-only use cases
let reader = handle.reader();§Thread Safety
This handle is Clone + Send + Sync and can be shared across tasks.
Implementations§
Source§impl ColdStorageHandle
impl ColdStorageHandle
Sourcepub fn reader(&self) -> ColdStorageReadHandle
pub fn reader(&self) -> ColdStorageReadHandle
Get a read-only handle that shares the read channel.
The returned handle can only perform read operations and cannot modify storage. Multiple read handles can coexist and query concurrently without affecting write throughput.
Sourcepub async fn append_block(&self, data: BlockData) -> ColdResult<()>
pub async fn append_block(&self, data: BlockData) -> ColdResult<()>
Append a single block to cold storage.
Sourcepub async fn append_blocks(&self, data: Vec<BlockData>) -> ColdResult<()>
pub async fn append_blocks(&self, data: Vec<BlockData>) -> ColdResult<()>
Append multiple blocks to cold storage.
Sourcepub async fn truncate_above(&self, block: BlockNumber) -> ColdResult<()>
pub async fn truncate_above(&self, block: BlockNumber) -> ColdResult<()>
Truncate all data above the given block number.
This removes block N+1 and higher from all tables.
Sourcepub fn dispatch_append_blocks(&self, data: Vec<BlockData>) -> ColdResult<()>
pub fn dispatch_append_blocks(&self, data: Vec<BlockData>) -> ColdResult<()>
Dispatch append blocks without waiting for response (non-blocking).
Unlike append_blocks, this method returns
immediately without waiting for the write to complete. The write
result is discarded.
§Errors
ColdStorageError::Backpressure: Channel is full. The task is alive but cannot keep up. Transient; may retry or accept the gap.ColdStorageError::TaskTerminated: Channel is closed. The task has stopped and must be restarted.
In both cases, hot storage already contains the data and remains authoritative.
Sourcepub fn dispatch_truncate_above(&self, block: BlockNumber) -> ColdResult<()>
pub fn dispatch_truncate_above(&self, block: BlockNumber) -> ColdResult<()>
Dispatch truncate without waiting for response (non-blocking).
Unlike truncate_above, this method returns
immediately without waiting for the truncate to complete. The result
is discarded.
§Errors
Same as dispatch_append_blocks. If
cold storage falls behind during a reorg, it may temporarily contain
stale data until the truncate is processed or replayed.
Methods from Deref<Target = ColdStorageReadHandle>§
Sourcepub async fn get_header(
&self,
spec: HeaderSpecifier,
) -> ColdResult<Option<SealedHeader>>
pub async fn get_header( &self, spec: HeaderSpecifier, ) -> ColdResult<Option<SealedHeader>>
Get a header by specifier.
Sourcepub async fn get_header_by_number(
&self,
block: BlockNumber,
) -> ColdResult<Option<SealedHeader>>
pub async fn get_header_by_number( &self, block: BlockNumber, ) -> ColdResult<Option<SealedHeader>>
Get a header by block number.
Sourcepub async fn get_header_by_hash(
&self,
hash: B256,
) -> ColdResult<Option<SealedHeader>>
pub async fn get_header_by_hash( &self, hash: B256, ) -> ColdResult<Option<SealedHeader>>
Get a header by block hash.
Sourcepub async fn get_headers(
&self,
specs: Vec<HeaderSpecifier>,
) -> ColdResult<Vec<Option<SealedHeader>>>
pub async fn get_headers( &self, specs: Vec<HeaderSpecifier>, ) -> ColdResult<Vec<Option<SealedHeader>>>
Get multiple headers by specifiers.
Sourcepub async fn get_transaction(
&self,
spec: TransactionSpecifier,
) -> ColdResult<Option<Confirmed<RecoveredTx>>>
pub async fn get_transaction( &self, spec: TransactionSpecifier, ) -> ColdResult<Option<Confirmed<RecoveredTx>>>
Get a transaction by specifier, with block confirmation metadata.
Sourcepub async fn get_tx_by_hash(
&self,
hash: B256,
) -> ColdResult<Option<Confirmed<RecoveredTx>>>
pub async fn get_tx_by_hash( &self, hash: B256, ) -> ColdResult<Option<Confirmed<RecoveredTx>>>
Get a transaction by hash.
Sourcepub async fn get_tx_by_block_and_index(
&self,
block: BlockNumber,
index: u64,
) -> ColdResult<Option<Confirmed<RecoveredTx>>>
pub async fn get_tx_by_block_and_index( &self, block: BlockNumber, index: u64, ) -> ColdResult<Option<Confirmed<RecoveredTx>>>
Get a transaction by block number and index.
Sourcepub async fn get_tx_by_block_hash_and_index(
&self,
block_hash: B256,
index: u64,
) -> ColdResult<Option<Confirmed<RecoveredTx>>>
pub async fn get_tx_by_block_hash_and_index( &self, block_hash: B256, index: u64, ) -> ColdResult<Option<Confirmed<RecoveredTx>>>
Get a transaction by block hash and index.
Sourcepub async fn get_transactions_in_block(
&self,
block: BlockNumber,
) -> ColdResult<Vec<RecoveredTx>>
pub async fn get_transactions_in_block( &self, block: BlockNumber, ) -> ColdResult<Vec<RecoveredTx>>
Get all transactions in a block.
Sourcepub async fn get_transaction_count(&self, block: BlockNumber) -> ColdResult<u64>
pub async fn get_transaction_count(&self, block: BlockNumber) -> ColdResult<u64>
Get the transaction count for a block.
Sourcepub async fn get_receipt(
&self,
spec: ReceiptSpecifier,
) -> ColdResult<Option<ColdReceipt>>
pub async fn get_receipt( &self, spec: ReceiptSpecifier, ) -> ColdResult<Option<ColdReceipt>>
Get a receipt by specifier.
Sourcepub async fn get_receipt_by_tx_hash(
&self,
hash: B256,
) -> ColdResult<Option<ColdReceipt>>
pub async fn get_receipt_by_tx_hash( &self, hash: B256, ) -> ColdResult<Option<ColdReceipt>>
Get a receipt by transaction hash.
Sourcepub async fn get_receipt_by_block_and_index(
&self,
block: BlockNumber,
index: u64,
) -> ColdResult<Option<ColdReceipt>>
pub async fn get_receipt_by_block_and_index( &self, block: BlockNumber, index: u64, ) -> ColdResult<Option<ColdReceipt>>
Get a receipt by block number and index.
Sourcepub async fn get_receipts_in_block(
&self,
block: BlockNumber,
) -> ColdResult<Vec<ColdReceipt>>
pub async fn get_receipts_in_block( &self, block: BlockNumber, ) -> ColdResult<Vec<ColdReceipt>>
Get all receipts in a block.
Sourcepub async fn get_signet_events(
&self,
spec: SignetEventsSpecifier,
) -> ColdResult<Vec<DbSignetEvent>>
pub async fn get_signet_events( &self, spec: SignetEventsSpecifier, ) -> ColdResult<Vec<DbSignetEvent>>
Get signet events by specifier.
Sourcepub async fn get_signet_events_in_block(
&self,
block: BlockNumber,
) -> ColdResult<Vec<DbSignetEvent>>
pub async fn get_signet_events_in_block( &self, block: BlockNumber, ) -> ColdResult<Vec<DbSignetEvent>>
Get signet events in a block.
Sourcepub async fn get_signet_events_in_range(
&self,
start: BlockNumber,
end: BlockNumber,
) -> ColdResult<Vec<DbSignetEvent>>
pub async fn get_signet_events_in_range( &self, start: BlockNumber, end: BlockNumber, ) -> ColdResult<Vec<DbSignetEvent>>
Get signet events in a range of blocks.
Sourcepub async fn get_zenith_header(
&self,
block: BlockNumber,
) -> ColdResult<Option<DbZenithHeader>>
pub async fn get_zenith_header( &self, block: BlockNumber, ) -> ColdResult<Option<DbZenithHeader>>
Get a zenith header by block number.
Sourcepub async fn get_zenith_headers(
&self,
spec: ZenithHeaderSpecifier,
) -> ColdResult<Vec<DbZenithHeader>>
pub async fn get_zenith_headers( &self, spec: ZenithHeaderSpecifier, ) -> ColdResult<Vec<DbZenithHeader>>
Get zenith headers by specifier.
Sourcepub async fn get_zenith_headers_in_range(
&self,
start: BlockNumber,
end: BlockNumber,
) -> ColdResult<Vec<DbZenithHeader>>
pub async fn get_zenith_headers_in_range( &self, start: BlockNumber, end: BlockNumber, ) -> ColdResult<Vec<DbZenithHeader>>
Get zenith headers in a range of blocks.
Sourcepub async fn get_logs(
&self,
filter: Filter,
max_logs: usize,
) -> ColdResult<Vec<RpcLog>>
pub async fn get_logs( &self, filter: Filter, max_logs: usize, ) -> ColdResult<Vec<RpcLog>>
Filter logs by block range, address, and topics.
Follows eth_getLogs semantics. Returns matching logs ordered by
(block_number, tx_index, log_index).
§Errors
Returns ColdStorageError::TooManyLogs if the query would produce
more than max_logs results.
Sourcepub async fn stream_logs(
&self,
filter: Filter,
max_logs: usize,
deadline: Duration,
) -> ColdResult<LogStream>
pub async fn stream_logs( &self, filter: Filter, max_logs: usize, deadline: Duration, ) -> ColdResult<LogStream>
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, etc.).
The deadline is clamped to the task’s configured maximum.
§Partial Delivery
One or more Ok(log) items may be delivered before a terminal
Err(...). Consumers must be prepared for partial results — for
example, a reorg or deadline expiry can interrupt a stream that
has already yielded some logs.
§Resource Management
The stream holds a backend concurrency permit. Dropping the stream releases the permit. Drop early if results are no longer needed.
Sourcepub async fn get_latest_block(&self) -> ColdResult<Option<BlockNumber>>
pub async fn get_latest_block(&self) -> ColdResult<Option<BlockNumber>>
Get the latest block number in storage.
Trait Implementations§
Source§impl Clone for ColdStorageHandle
impl Clone for ColdStorageHandle
Source§fn clone(&self) -> ColdStorageHandle
fn clone(&self) -> ColdStorageHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColdStorageHandle
impl Debug for ColdStorageHandle
Auto Trait Implementations§
impl Freeze for ColdStorageHandle
impl RefUnwindSafe for ColdStorageHandle
impl Send for ColdStorageHandle
impl Sync for ColdStorageHandle
impl Unpin for ColdStorageHandle
impl UnsafeUnpin for ColdStorageHandle
impl UnwindSafe for ColdStorageHandle
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> 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.