Rename merkle_root to state_id
This commit is contained in:
parent
26495e973e
commit
326eb56b62
@ -20,7 +20,7 @@ pub struct ProcessState {
|
||||
pub commited_in: OutPoint,
|
||||
#[tsify(type = "Record<string, string>")]
|
||||
pub pcd_commitment: Value, // If we can't modify a field, we just copy the previous value
|
||||
pub merkle_root: String, // the root of the tree created with all the commitments. Serves as an unique id for a state too
|
||||
pub state_id: String, // the root of the tree created with all the commitments. Serves as an unique id for a state too
|
||||
#[tsify(type = "Record<string, string>")]
|
||||
pub encrypted_pcd: Value, // Some fields may be clear, if the owner of the process decides so
|
||||
#[tsify(type = "Record<string, string>")]
|
||||
@ -54,7 +54,7 @@ impl ProcessState {
|
||||
let res = Self {
|
||||
commited_in,
|
||||
pcd_commitment,
|
||||
merkle_root,
|
||||
state_id: merkle_root,
|
||||
encrypted_pcd: Value::Object(encrypted),
|
||||
keys,
|
||||
validation_tokens: vec![],
|
||||
@ -193,7 +193,7 @@ impl ProcessState {
|
||||
}
|
||||
|
||||
let mut merkle_root = [0u8; 32];
|
||||
merkle_root.copy_from_slice(&Vec::from_hex(&self.merkle_root).unwrap());
|
||||
merkle_root.copy_from_slice(&Vec::from_hex(&self.state_id).unwrap());
|
||||
|
||||
applicable_roles.into_iter().any(|role_def| {
|
||||
role_def.validation_rules.iter().any(|rule| {
|
||||
@ -354,14 +354,14 @@ impl Process {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_state_for_commitments_root(&self, merkle_root: &str) -> anyhow::Result<&ProcessState> {
|
||||
pub fn get_state_for_id(&self, state_id: &str) -> anyhow::Result<&ProcessState> {
|
||||
if self.get_number_of_states() == 0 {
|
||||
// This should never happen, but we better get rid of it now
|
||||
return Err(anyhow::Error::msg("process is empty".to_owned()));
|
||||
}
|
||||
|
||||
for p in self.get_latest_concurrent_states()? {
|
||||
if merkle_root == p.merkle_root.as_str() {
|
||||
if state_id == p.state_id.as_str() {
|
||||
return Ok(p);
|
||||
}
|
||||
}
|
||||
@ -369,14 +369,14 @@ impl Process {
|
||||
return Err(anyhow::Error::msg("No state for this merkle root"));
|
||||
}
|
||||
|
||||
pub fn get_state_for_commitments_root_mut(&mut self, merkle_root: &str) -> anyhow::Result<&mut ProcessState> {
|
||||
pub fn get_state_for_id_mut(&mut self, state_id: &str) -> anyhow::Result<&mut ProcessState> {
|
||||
if self.get_number_of_states() == 0 {
|
||||
// This should never happen, but we better get rid of it now
|
||||
return Err(anyhow::Error::msg("process is empty".to_owned()));
|
||||
}
|
||||
|
||||
for p in self.get_latest_concurrent_states_mut()? {
|
||||
if merkle_root == p.merkle_root.as_str() {
|
||||
if state_id == p.state_id.as_str() {
|
||||
return Ok(p);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user