Add descriptions field in ProcessState
This commit is contained in:
parent
18dd726cce
commit
09ec91c243
@ -24,10 +24,16 @@ pub struct ProcessState {
|
|||||||
pub encrypted_pcd: Value, // Some fields may be clear, if the owner of the process decides so
|
pub encrypted_pcd: Value, // Some fields may be clear, if the owner of the process decides so
|
||||||
pub keys: Map<String, Value>, // We may not always have all the keys
|
pub keys: Map<String, Value>, // We may not always have all the keys
|
||||||
pub validation_tokens: Vec<Proof>, // Signature of the hash of the encrypted pcd tagged with some decision like "yes" or "no"
|
pub validation_tokens: Vec<Proof>, // Signature of the hash of the encrypted pcd tagged with some decision like "yes" or "no"
|
||||||
|
pub descriptions: Map<String, Value>, // long descriptions that can be used for the ihm
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcessState {
|
impl ProcessState {
|
||||||
pub fn new(commited_in: OutPoint, clear_state: Map<String, Value>) -> anyhow::Result<Self> {
|
pub fn new(commited_in: OutPoint, clear_state: Map<String, Value>, descriptions: Map<String, Value>) -> anyhow::Result<Self> {
|
||||||
|
// Check all descriptions matches clear_state
|
||||||
|
for (key, _) in &descriptions {
|
||||||
|
clear_state.get(key).ok_or(anyhow::Error::msg("Missing field in descriptions"))?;
|
||||||
|
}
|
||||||
|
|
||||||
let mut keys = Map::new();
|
let mut keys = Map::new();
|
||||||
let mut encrypted = Map::new();
|
let mut encrypted = Map::new();
|
||||||
|
|
||||||
@ -49,6 +55,7 @@ impl ProcessState {
|
|||||||
encrypted_pcd: Value::Object(encrypted),
|
encrypted_pcd: Value::Object(encrypted),
|
||||||
keys,
|
keys,
|
||||||
validation_tokens: vec![],
|
validation_tokens: vec![],
|
||||||
|
descriptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
@ -627,7 +634,7 @@ mod tests {
|
|||||||
|
|
||||||
let outpoint = OutPoint::null();
|
let outpoint = OutPoint::null();
|
||||||
|
|
||||||
ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone()).unwrap()
|
ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone(), Map::new()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user