pub struct Cache { /* private fields */ }Expand description
In-memory caches for decoded transactions and resolved prevouts.
Shared across the graph builder and server via Arc<Cache>.
Uses a concurrent quick cache implementation so lookups and inserts
do not require an external async mutex.
Entries are evicted automatically once the configured capacities are reached.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn with_capacity(tx_cap: usize, prevout_cap: usize) -> Self
pub fn with_capacity(tx_cap: usize, prevout_cap: usize) -> Self
Create a cache with explicit capacities. Both values must be > 0.
Sourcepub async fn get_tx(&self, txid: &Txid) -> Option<TxNode>
pub async fn get_tx(&self, txid: &Txid) -> Option<TxNode>
Look up a cached transaction by txid.
Sourcepub async fn insert_tx(&self, txid: Txid, node: TxNode)
pub async fn insert_tx(&self, txid: Txid, node: TxNode)
Insert a decoded transaction into the cache.
Sourcepub async fn get_prevout(&self, txid: &Txid, vout: u32) -> Option<TxOutput>
pub async fn get_prevout(&self, txid: &Txid, vout: u32) -> Option<TxOutput>
Look up cached prevout info for a specific outpoint.
Sourcepub async fn insert_prevout(&self, txid: Txid, vout: u32, info: TxOutput)
pub async fn insert_prevout(&self, txid: Txid, vout: u32, info: TxOutput)
Cache resolved prevout data for a specific outpoint.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cache
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl !UnwindSafe for Cache
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