Skip to content

Commit

Permalink
use create_tree_d func to generate tree-d file
Browse files Browse the repository at this point in the history
  • Loading branch information
ta0li committed Mar 14, 2022
1 parent b36cb06 commit 4420178
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 39 deletions.
16 changes: 12 additions & 4 deletions venus-worker/src/bin/venus-worker/generator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use anyhow::{anyhow, Result};
use byte_unit::Byte;
use clap::{value_t, App, AppSettings, Arg, ArgMatches, SubCommand};
use std::convert::TryFrom;
use std::path::PathBuf;
use tracing::{error, info};

use venus_worker::generate_static_tree_d;
use venus_worker::create_tree_d;

use venus_worker::{RegisteredSealProof, SealProof};

pub const SUB_CMD_NAME: &str = "generator";

pub fn subcommand<'a, 'b>() -> App<'a, 'b> {
let pieces_cmd = SubCommand::with_name("tree-d")
let tree_d_cmd = SubCommand::with_name("tree-d")
.arg(
Arg::with_name("sector-size")
.long("sector-size")
Expand All @@ -26,7 +30,7 @@ pub fn subcommand<'a, 'b>() -> App<'a, 'b> {

SubCommand::with_name(SUB_CMD_NAME)
.setting(AppSettings::ArgRequiredElseHelp)
.subcommand(pieces_cmd)
.subcommand(tree_d_cmd)
}

pub(crate) fn submatch<'a>(subargs: &ArgMatches<'a>) -> Result<()> {
Expand All @@ -36,7 +40,11 @@ pub(crate) fn submatch<'a>(subargs: &ArgMatches<'a>) -> Result<()> {
let size = Byte::from_str(size_str)?;
let path = value_t!(m, "path", String)?;

match generate_static_tree_d(size.get_bytes() as u64, path) {
let proof_type = SealProof::try_from(size.get_bytes() as u64)?;
let registered_proof = RegisteredSealProof::from(proof_type);
let cache_dir = PathBuf::from(&path);

match create_tree_d(registered_proof, None, cache_dir) {
Ok(_) => info!("generate static tree-d succeed"),
Err(e) => error!("generate static tree-d {}", e),
}
Expand Down
5 changes: 3 additions & 2 deletions venus-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ mod util;
pub use config::Config;
pub use infra::objstore;
pub use run::{start_deamon, start_mock};
pub use sealing::generator::generate_static_tree_d;
pub use sealing::processor::{
create_tree_d,
external::sub::{run, run_c2, run_pc1, run_pc2, run_tree_d},
Input, SnapProveReplicaUpdateInput, SnapReplicaUpdateInput,
Input, RegisteredSealProof, SnapProveReplicaUpdateInput, SnapReplicaUpdateInput,
};
pub use sealing::store;
pub use sealing::util as seal_util;
pub use types::SealProof;
pub use util::task::block_on;
pub use watchdog::dones;

Expand Down
32 changes: 0 additions & 32 deletions venus-worker/src/sealing/generator.rs

This file was deleted.

1 change: 0 additions & 1 deletion venus-worker/src/sealing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

mod worker;

pub mod generator;
pub mod processor;
pub mod resource;
pub mod service;
Expand Down
1 change: 1 addition & 0 deletions venus-worker/src/sealing/processor/safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub fn seal_pre_commit_phase2(
}
}

/// create tree-d file
pub fn create_tree_d(
registered_proof: RegisteredSealProof,
in_path: Option<PathBuf>,
Expand Down

0 comments on commit 4420178

Please sign in to comment.