Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean up public API for clearing files #1771

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 2 additions & 38 deletions filecoin-proofs/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ pub use winning_post::*;

pub use storage_proofs_update::constants::{partition_count, TreeRHasher};

// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking
// the public API. Once we break the API, remove that generic.
// Ensure that any associated cached data persisted is discarded.
pub fn clear_cache<Tree>(cache_dir: &Path) -> Result<()> {
pub fn clear_cache(cache_dir: &Path) -> Result<()> {
info!("clear_cache:start");

let result = stacked::clear_cache_dir(cache_dir);
Expand All @@ -64,40 +61,7 @@ pub fn clear_cache<Tree>(cache_dir: &Path) -> Result<()> {
result
}

// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking
// the public API. Once we break the API, remove that generic.
// Ensure that any associated cached data persisted is discarded.
pub fn clear_caches<Tree: MerkleTreeTrait>(
replicas: &BTreeMap<SectorId, PrivateReplicaInfo<Tree>>,
) -> Result<()> {
info!("clear_caches:start");

for replica in replicas.values() {
clear_cache::<Tree>(replica.cache_dir.as_path())?;
}

info!("clear_caches:finish");

Ok(())
}

// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking
// the public API. Once we break the API, remove that generic.
// Ensure that any persisted layer data generated from porep are discarded.
pub fn clear_layer_data<Tree>(cache_dir: &Path) -> Result<()> {
info!("clear_layer_data:start");

let result = stacked::clear_cache_dir(cache_dir);

info!("clear_layer_data:finish");

result
}

// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking
// the public API. Once we break the API, remove that generic.
// Ensure that any persisted vanilla proofs generated from synthetic porep are discarded.
pub fn clear_synthetic_proofs<Tree>(cache_dir: &Path) -> Result<()> {
pub fn clear_synthetic_proofs(cache_dir: &Path) -> Result<()> {
info!("clear_synthetic_proofs:start");

let result = stacked::clear_synthetic_proofs(cache_dir);
Expand Down
Loading