pub struct QueryMinimizingExplorer<E: BlockchainExplorer> { /* private fields */ }Expand description
Wraps any BlockchainExplorer with caching and rate limiting to reduce
redundant API calls to the underlying explorer.
Implementations§
Source§impl<E: BlockchainExplorer> QueryMinimizingExplorer<E>
impl<E: BlockchainExplorer> QueryMinimizingExplorer<E>
Sourcepub fn new(inner: E, config: QueryMinimizationConfig) -> Self
pub fn new(inner: E, config: QueryMinimizationConfig) -> Self
Create a new QueryMinimizingExplorer wrapping inner.
Sourcepub fn query_count(&self) -> u64
pub fn query_count(&self) -> u64
Total number of queries forwarded to the inner explorer.
Sourcepub fn cache_hit_count(&self) -> u64
pub fn cache_hit_count(&self) -> u64
Total number of cache hits (queries served from cache).
Sourcepub fn cache_hit_rate(&self) -> f64
pub fn cache_hit_rate(&self) -> f64
Fraction of all requests served from cache: cache_hits / (cache_hits + queries).
Returns 0.0 if no requests have been made yet.
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Remove expired entries from both caches.
Trait Implementations§
Source§impl<E: BlockchainExplorer> BlockchainExplorer for QueryMinimizingExplorer<E>
impl<E: BlockchainExplorer> BlockchainExplorer for QueryMinimizingExplorer<E>
Source§fn get_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
txid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExplorerTransaction, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
txid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExplorerTransaction, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a transaction by its txid.
Source§fn get_address_info<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExplorerAddress, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_address_info<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExplorerAddress, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve address metadata and balance.
Source§fn get_utxos<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ExplorerUtxo>, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_utxos<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ExplorerUtxo>, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the unspent outputs for an address.
Source§fn broadcast_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
hex: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn broadcast_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
hex: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Broadcast a raw transaction (hex-encoded) to the network. Read more
Source§fn get_block_height<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_block_height<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, BitcoinError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the current confirmed block height.
Auto Trait Implementations§
impl<E> !Freeze for QueryMinimizingExplorer<E>
impl<E> RefUnwindSafe for QueryMinimizingExplorer<E>where
E: RefUnwindSafe,
impl<E> Send for QueryMinimizingExplorer<E>
impl<E> Sync for QueryMinimizingExplorer<E>
impl<E> Unpin for QueryMinimizingExplorer<E>where
E: Unpin,
impl<E> UnsafeUnpin for QueryMinimizingExplorer<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for QueryMinimizingExplorer<E>where
E: UnwindSafe,
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
Mutably borrows from an owned value. Read more