fix(rln): tree_config parsing (#180)

* fix(rln): tree_config parsing

* fix(rln): clippy
This commit is contained in:
Aaryamann Challani 2023-06-16 15:49:56 +05:30 committed by GitHub
parent 8cfd83de54
commit be88a432d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -80,18 +80,17 @@ impl RLN<'_> {
let resources_folder = rln_config["resources_folder"]
.as_str()
.unwrap_or(TEST_RESOURCES_FOLDER);
let tree_config_opt = rln_config["tree_config"].as_str();
let tree_config = rln_config["tree_config"].to_string();
let witness_calculator = circom_from_folder(resources_folder)?;
let proving_key = zkey_from_folder(resources_folder)?;
let verification_key = vk_from_folder(resources_folder)?;
let tree_config: <PoseidonTree as ZerokitMerkleTree>::Config = match tree_config_opt {
Some(tree_config_str) => {
<PoseidonTree as ZerokitMerkleTree>::Config::from_str(tree_config_str)?
}
None => <PoseidonTree as ZerokitMerkleTree>::Config::default(),
let tree_config: <PoseidonTree as ZerokitMerkleTree>::Config = if tree_config.is_empty() {
<PoseidonTree as ZerokitMerkleTree>::Config::default()
} else {
<PoseidonTree as ZerokitMerkleTree>::Config::from_str(&tree_config)?
};
// We compute a default empty tree