mina_tree/scan_state/transaction_logic/zkapp_command/
from_applied_sequence.rs1use mina_curves::pasta::Fp;
2use std::collections::HashMap;
3
4use super::{AccountId, ToVerifiableCache, ToVerifiableStrategy, VerificationKeyWire};
5
6pub struct Cache {
7 cache: HashMap<AccountId, VerificationKeyWire>,
8}
9
10impl Cache {
11 pub fn new(cache: HashMap<AccountId, 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 self.cache
19 .get(account_id)
20 .filter(|vk| &vk.hash() == vk_hash)
21 }
22
23 fn add(&mut self, account_id: AccountId, vk: VerificationKeyWire) {
24 self.cache.insert(account_id, vk);
25 }
26}
27
28pub struct FromAppliedSequence;
29
30impl ToVerifiableStrategy for FromAppliedSequence {
31 type Cache = Cache;
32}