-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from ipfs-force-community/feat/lt/speed_cc_sector
Opt: skip AP for cc sector
- Loading branch information
Showing
5 changed files
with
103 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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::create_tree_d; | ||
|
||
use venus_worker::{RegisteredSealProof, SealProof}; | ||
|
||
pub const SUB_CMD_NAME: &str = "generator"; | ||
|
||
pub fn subcommand<'a, 'b>() -> App<'a, 'b> { | ||
let tree_d_cmd = SubCommand::with_name("tree-d") | ||
.arg( | ||
Arg::with_name("sector-size") | ||
.long("sector-size") | ||
.short("s") | ||
.takes_value(true) | ||
.help("sector size"), | ||
) | ||
.arg( | ||
Arg::with_name("path") | ||
.long("path") | ||
.short("p") | ||
.takes_value(true) | ||
.help("path for the staic-tree-d"), | ||
); | ||
|
||
SubCommand::with_name(SUB_CMD_NAME) | ||
.setting(AppSettings::ArgRequiredElseHelp) | ||
.subcommand(tree_d_cmd) | ||
} | ||
|
||
pub(crate) fn submatch<'a>(subargs: &ArgMatches<'a>) -> Result<()> { | ||
match subargs.subcommand() { | ||
("tree-d", Some(m)) => { | ||
let size_str = value_t!(m, "sector-size", String)?; | ||
let size = Byte::from_str(size_str)?; | ||
let path = value_t!(m, "path", String)?; | ||
|
||
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), | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
(other, _) => Err(anyhow!("unexpected subcommand `{}` of generator", other)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters