mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 09:54:09 +01:00
Fix cache methods' scope
This commit is contained in:
parent
ced9796bde
commit
9a45d9c798
10
src/cache.rs
10
src/cache.rs
@ -7,24 +7,24 @@ use std::sync::Arc;
|
||||
use crate::merkle::Proof;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Cache {
|
||||
pub(crate) struct Cache {
|
||||
txs: Arc<RwLock<HashMap<Txid, Transaction>>>,
|
||||
proofs: Arc<RwLock<HashMap<(BlockHash, Txid), Proof>>>,
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
pub(crate) fn add_tx(&self, txid: Txid, f: impl FnOnce() -> Transaction) {
|
||||
pub fn add_tx(&self, txid: Txid, f: impl FnOnce() -> Transaction) {
|
||||
self.txs.write().entry(txid).or_insert_with(f);
|
||||
}
|
||||
|
||||
pub(crate) fn get_tx<F, T>(&self, txid: &Txid, f: F) -> Option<T>
|
||||
pub fn get_tx<F, T>(&self, txid: &Txid, f: F) -> Option<T>
|
||||
where
|
||||
F: FnOnce(&Transaction) -> T,
|
||||
{
|
||||
self.txs.read().get(txid).map(f)
|
||||
}
|
||||
|
||||
pub(crate) fn add_proof<F>(&self, blockhash: BlockHash, txid: Txid, f: F)
|
||||
pub fn add_proof<F>(&self, blockhash: BlockHash, txid: Txid, f: F)
|
||||
where
|
||||
F: FnOnce() -> Proof,
|
||||
{
|
||||
@ -34,7 +34,7 @@ impl Cache {
|
||||
.or_insert_with(f);
|
||||
}
|
||||
|
||||
pub(crate) fn get_proof<F, T>(&self, blockhash: BlockHash, txid: Txid, f: F) -> Option<T>
|
||||
pub fn get_proof<F, T>(&self, blockhash: BlockHash, txid: Txid, f: F) -> Option<T>
|
||||
where
|
||||
F: FnOnce(&Proof) -> T,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user