feat: integrate mt in mock_sign (#23)
* feat: integrate mt in mock_sign * fix: handle compile error * fix: use PodClass::Main in MainPod origin
This commit is contained in:
parent
4d16647d10
commit
085d5fff2c
5 changed files with 51 additions and 81 deletions
|
|
@ -1,4 +1,3 @@
|
|||
// TODO: Move the SignedPod.id calculation to mock_signed
|
||||
// TODO: Move the MainPod logic to mock_main and implement the MainPod trait
|
||||
/*
|
||||
use anyhow::Result;
|
||||
|
|
@ -11,29 +10,6 @@ use std::iter;
|
|||
use crate::merkletree::MerkleTree;
|
||||
use crate::middleware::{Hash, Params, PodId, Value, NULL};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SignedPod {
|
||||
pub params: Params,
|
||||
pub id: PodId,
|
||||
pub kvs: MerkleTree,
|
||||
}
|
||||
|
||||
impl SignedPod {
|
||||
pub fn new(params: &Params, kvs: HashMap<Hash, Value>) -> Result<Self> {
|
||||
let mt = MerkleTree::new(kvs);
|
||||
let root = mt.root()?;
|
||||
Ok(Self {
|
||||
params: *params,
|
||||
id: PodId(root),
|
||||
kvs: mt,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.id.0 == NULL
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MainPod {
|
||||
pub params: Params,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue