Skip to content

Commit bb821ac

Browse files
committed
Ledger/scan_state/tx-logic: split zkapp_command into submodules
1 parent ac3eec3 commit bb821ac

File tree

6 files changed

+295
-274
lines changed

6 files changed

+295
-274
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use mina_curves::pasta::Fp;
2+
use std::collections::HashMap;
3+
4+
use super::{AccountId, ToVerifiableCache, ToVerifiableStrategy, VerificationKeyWire};
5+
6+
pub struct Cache {
7+
cache: HashMap<AccountId, VerificationKeyWire>,
8+
}
9+
10+
impl Cache {
11+
pub fn new(cache: HashMap<AccountId, VerificationKeyWire>) -> Self {
12+
Self { cache }
13+
}
14+
}
15+
16+
impl 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+
28+
pub struct FromAppliedSequence;
29+
30+
impl ToVerifiableStrategy for FromAppliedSequence {
31+
type Cache = Cache;
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use mina_curves::pasta::Fp;
2+
use std::collections::HashMap;
3+
4+
use super::{AccountId, ToVerifiableCache, ToVerifiableStrategy, VerificationKeyWire};
5+
6+
pub struct Cache {
7+
cache: HashMap<AccountId, HashMap<Fp, VerificationKeyWire>>,
8+
}
9+
10+
impl Cache {
11+
pub fn new(cache: HashMap<AccountId, HashMap<Fp, VerificationKeyWire>>) -> Self {
12+
Self { cache }
13+
}
14+
}
15+
16+
impl 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+
28+
pub struct FromUnappliedSequence;
29+
30+
impl ToVerifiableStrategy for FromUnappliedSequence {
31+
type Cache = Cache;
32+
}

0 commit comments

Comments
 (0)