ckb_verification/
cache.rsuse ckb_script::TransactionSnapshot;
use ckb_types::{
core::{Capacity, Cycle, EntryCompleted},
packed::Byte32,
};
use std::sync::Arc;
pub type TxVerificationCache = lru::LruCache<Byte32, CacheEntry>;
const CACHE_SIZE: usize = 1000 * 30;
pub fn init_cache() -> TxVerificationCache {
lru::LruCache::new(CACHE_SIZE)
}
pub type CacheEntry = Completed;
#[derive(Clone, Debug)]
pub struct Suspended {
pub fee: Capacity,
pub snap: Arc<TransactionSnapshot>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Completed {
pub cycles: Cycle,
pub fee: Capacity,
}
impl From<Completed> for EntryCompleted {
fn from(value: Completed) -> Self {
EntryCompleted {
cycles: value.cycles,
fee: value.fee,
}
}
}