mina_tree/scan_state/transaction_logic/zkapp_command/
from_unapplied_sequence.rs

1use mina_curves::pasta::Fp;
2use std::collections::HashMap;
3
4use super::{AccountId, ToVerifiableCache, ToVerifiableStrategy, VerificationKeyWire};
5
6pub struct Cache {
7    cache: HashMap<AccountId, HashMap<Fp, VerificationKeyWire>>,
8}
9
10impl Cache {
11    pub fn new(cache: HashMap<AccountId, HashMap<Fp, VerificationKeyWire>>) -> Self {
12        Self { cache }
13    }
14}
15
16impl ToVerifiableCache for Cache {
17    fn find(&self, account_id: &AccountId, vk_hash: &Fp) -> Option<&VerificationKeyWire> {
18        let vks = self.cache.get(account_id)?;
19        vks.get(vk_hash)
20    }
21
22    fn add(&mut self, account_id: AccountId, vk: VerificationKeyWire) {
23        let vks = self.cache.entry(account_id).or_default();
24        vks.insert(vk.hash(), vk);
25    }
26}
27
28pub struct FromUnappliedSequence;
29
30impl ToVerifiableStrategy for FromUnappliedSequence {
31    type Cache = Cache;
32}