|
1 | 1 | use std::path::PathBuf; |
2 | 2 |
|
| 3 | +use anyhow::Result; |
| 4 | + |
3 | 5 | use paired::bls12_381::Bls12; |
4 | 6 | use storage_proofs::circuit::election_post::{ElectionPoStCircuit, ElectionPoStCompound}; |
5 | 7 | use storage_proofs::drgraph::DefaultTreeHasher; |
@@ -30,28 +32,30 @@ impl From<PoStConfig> for UnpaddedBytesAmount { |
30 | 32 |
|
31 | 33 | impl PoStConfig { |
32 | 34 | /// Returns the cache identifier as used by `storage-proofs::paramater_cache`. |
33 | | - pub fn get_cache_identifier(self) -> String { |
34 | | - let params = crate::parameters::post_public_params(self); |
35 | | - |
36 | | - <ElectionPoStCompound<DefaultTreeHasher> as CacheableParameters< |
37 | | - Bls12, |
38 | | - ElectionPoStCircuit<_, DefaultTreeHasher>, |
39 | | - _, |
40 | | - >>::cache_identifier(¶ms) |
| 35 | + pub fn get_cache_identifier(self) -> Result<String> { |
| 36 | + let params = crate::parameters::post_public_params(self)?; |
| 37 | + |
| 38 | + Ok( |
| 39 | + <ElectionPoStCompound<DefaultTreeHasher> as CacheableParameters< |
| 40 | + Bls12, |
| 41 | + ElectionPoStCircuit<_, DefaultTreeHasher>, |
| 42 | + _, |
| 43 | + >>::cache_identifier(¶ms), |
| 44 | + ) |
41 | 45 | } |
42 | 46 |
|
43 | | - pub fn get_cache_metadata_path(self) -> PathBuf { |
44 | | - let id = self.get_cache_identifier(); |
45 | | - parameter_cache::parameter_cache_metadata_path(&id) |
| 47 | + pub fn get_cache_metadata_path(self) -> Result<PathBuf> { |
| 48 | + let id = self.get_cache_identifier()?; |
| 49 | + Ok(parameter_cache::parameter_cache_metadata_path(&id)) |
46 | 50 | } |
47 | 51 |
|
48 | | - pub fn get_cache_verifying_key_path(self) -> PathBuf { |
49 | | - let id = self.get_cache_identifier(); |
50 | | - parameter_cache::parameter_cache_verifying_key_path(&id) |
| 52 | + pub fn get_cache_verifying_key_path(self) -> Result<PathBuf> { |
| 53 | + let id = self.get_cache_identifier()?; |
| 54 | + Ok(parameter_cache::parameter_cache_verifying_key_path(&id)) |
51 | 55 | } |
52 | 56 |
|
53 | | - pub fn get_cache_params_path(self) -> PathBuf { |
54 | | - let id = self.get_cache_identifier(); |
55 | | - parameter_cache::parameter_cache_params_path(&id) |
| 57 | + pub fn get_cache_params_path(self) -> Result<PathBuf> { |
| 58 | + let id = self.get_cache_identifier()?; |
| 59 | + Ok(parameter_cache::parameter_cache_params_path(&id)) |
56 | 60 | } |
57 | 61 | } |
0 commit comments