rename some old id to sts_hash (#402)

This commit is contained in:
Eduard S. 2025-08-28 02:48:43 +02:00 committed by GitHub
parent 0e2f7b756e
commit 511efa8d44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 23 additions and 37 deletions

View file

@ -136,7 +136,7 @@ impl fmt::Display for MainPodBuilder {
writeln!(f, "MainPod:")?;
writeln!(f, " input_main_pods:")?;
for in_pod in &self.input_pods {
writeln!(f, " - {}", in_pod.id())?;
writeln!(f, " - {}", in_pod.statements_hash())?;
}
writeln!(f, " statements:")?;
for (st, op) in self.statements.iter().zip_eq(self.operations.iter()) {
@ -662,25 +662,9 @@ impl fmt::Display for MainPod {
}
impl MainPod {
pub fn id(&self) -> Hash {
pub fn statements_hash(&self) -> Hash {
self.pod.statements_hash()
}
/// Returns the value of a Equal statement with self id that defines key if it exists.
pub fn get(&self, key: impl Into<Key>) -> Option<Value> {
let key: Key = key.into();
self.public_statements
.iter()
.find_map(|st| match st {
Statement::Equal(ValueRef::Key(ak), ValueRef::Literal(value))
if ak.root == self.id() && ak.key.hash() == key.hash() =>
{
Some(value)
}
_ => None,
})
.cloned()
}
}
struct MainPodCompilerInputs<'a> {

View file

@ -13,15 +13,15 @@ use crate::{
pub struct SerializedMainPod {
params: Params,
pod_type: (usize, String),
id: Hash,
sts_hash: Hash,
vd_set: VDSet,
public_statements: Vec<Statement>,
data: serde_json::Value,
}
impl SerializedMainPod {
pub fn id(&self) -> Hash {
self.id
pub fn statements_hash(&self) -> Hash {
self.sts_hash
}
}
@ -31,7 +31,7 @@ impl From<MainPod> for SerializedMainPod {
let data = pod.pod.serialize_data();
SerializedMainPod {
pod_type: (pod_type, pod_type_name_str.to_string()),
id: pod.id(),
sts_hash: pod.statements_hash(),
vd_set: pod.pod.vd_set().clone(),
params: pod.params.clone(),
public_statements: pod.pod.pub_statements(),
@ -47,7 +47,7 @@ impl TryFrom<SerializedMainPod> for MainPod {
let pod = deserialize_pod(
serialized.pod_type.0,
serialized.params.clone(),
serialized.id,
serialized.sts_hash,
serialized.vd_set,
serialized.data,
)?;