Skip to content

Commit e7bbbf9

Browse files
authored
Update signatures.rs
1 parent 1370bad commit e7bbbf9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/evm/traces/src/identifier/signatures.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ impl SignaturesCache {
108108
}
109109
}
110110

111+
/// Saves the cache to a file and returns an error if it fails.
112+
#[instrument(target = "evm::traces", name = "SignaturesCache::save_result", skip(self))]
113+
pub fn save_result(&self, path: &Path) -> Result<()> {
114+
if let Some(parent) = path.parent() {
115+
std::fs::create_dir_all(parent)
116+
.map_err(|err| eyre::eyre!("failed to create cache directory: {err}"))?;
117+
}
118+
fs::write_json_file(path, self)
119+
.map_err(|err| eyre::eyre!("failed to flush signature cache: {err}"))?;
120+
trace!(target: "evm::traces", "flushed signature cache");
121+
Ok(())
122+
}
123+
111124
/// Updates the cache from an ABI.
112125
pub fn extend_from_abi(&mut self, abi: &JsonAbi) {
113126
self.extend(abi.items().filter_map(|item| match item {

0 commit comments

Comments
 (0)