use alloc::{collections::BTreeMap, sync::Arc};
use miden_core::{Word, mast::MastForest};
pub trait MastForestStore {
fn get(&self, procedure_hash: &Word) -> Option<Arc<MastForest>>;
}
#[derive(Debug, Default, Clone)]
pub struct MemMastForestStore {
mast_forests: BTreeMap<Word, Arc<MastForest>>,
}
impl MemMastForestStore {
pub fn insert(&mut self, mast_forest: Arc<MastForest>) {
for proc_digest in mast_forest.local_procedure_digests() {
self.mast_forests.insert(proc_digest, mast_forest.clone());
}
}
}
impl MastForestStore for MemMastForestStore {
fn get(&self, procedure_hash: &Word) -> Option<Arc<MastForest>> {
self.mast_forests.get(procedure_hash).cloned()
}
}