From cc8d64f6ce39e7781f9638a9e35a9eec2e14fa06 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Tue, 17 Dec 2024 23:43:58 +0100 Subject: [PATCH] Add up_to_date_roles to UpdatedProcess --- src/api.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index 3a33ccf..f4e55c6 100644 --- a/src/api.rs +++ b/src/api.rs @@ -108,6 +108,7 @@ pub struct UserDiff { pub struct UpdatedProcess { pub commitment_tx: OutPoint, pub current_process: Process, + pub up_to_date_roles: HashMap, pub new_diffs: Vec, // All diffs should have the same new_state_merkle_root pub modified_state: Option, // basically when we add/receive validation proofs for a state // I think we should never have both new_state and modified_state @@ -878,6 +879,7 @@ fn handle_prd( commitment_tx: outpoint, current_process: relevant_process.clone(), new_diffs: diffs, + up_to_date_roles: roles, ..Default::default() }; @@ -1207,6 +1209,7 @@ pub fn create_new_process( let updated_process = UpdatedProcess { commitment_tx: outpoint, current_process: process, + up_to_date_roles: roles, new_diffs: diffs, ..Default::default() }; @@ -1236,9 +1239,11 @@ pub fn update_process( let last_state_commitments = &prev_state.pcd_commitment; let last_state_descriptions = &prev_state.descriptions; - let clear_new_state = Value::from_str(&new_state_str)?.to_value_object()?; + let clear_new_state = Value::from_str(&new_state_str)?; - let new_state = ProcessState::new(prev_state.commited_in, clear_new_state.clone(), last_state_descriptions.clone())?; + let roles = clear_new_state.extract_roles()?; + + let new_state = ProcessState::new(prev_state.commited_in, clear_new_state.to_value_object()?, last_state_descriptions.clone())?; // We compare the new state with the previous one let last_state_merkle_root = &prev_state.merkle_root; @@ -1261,6 +1266,7 @@ pub fn update_process( let updated_process = UpdatedProcess { commitment_tx: outpoint, current_process: process.clone(), + up_to_date_roles: roles, new_diffs: diffs, ..Default::default() };