Skip to content

Commit

Permalink
feat: phase2-cli parse command (#1247)
Browse files Browse the repository at this point in the history
`phase2 parse` prints information about large or small non-ram params without having to deserialize the entire file (only deserializes 6 points). This is useful when verifying that small and large files are equivalent, e.g. can be used to verify the output of `phase2 merge`.
  • Loading branch information
DrPeterVanNostrand authored Aug 5, 2020
1 parent 3b01736 commit 90a9985
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions filecoin-proofs/src/bin/phase2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,14 @@ fn main() {
.help("The path to the file that contains all the data."),
);

let parse_command = SubCommand::with_name("parse")
.about("Parses file info from large or small-nonraw params")
.arg(
Arg::with_name("path")
.required(true)
.help("Path to params file."),
);

let matches = App::new("phase2")
.version("1.0")
.setting(AppSettings::ArgRequiredElseHelp)
Expand All @@ -1431,6 +1439,7 @@ fn main() {
.subcommand(convert_command)
.subcommand(merge_command)
.subcommand(split_keys_command)
.subcommand(parse_command)
.get_matches();

if let (subcommand, Some(matches)) = matches.subcommand() {
Expand Down Expand Up @@ -1967,6 +1976,22 @@ fn main() {
.unwrap_or_else(|_| panic!("failed to write info data to {}", info_path));
}
}
"parse" => {
let path = matches.value_of("path").unwrap();
let (_, _, _, _, _, size, raw) = parse_params_filename(&path);

if raw {
unimplemented!("`parse` command does not currently support raw params");
}

let file_info = if size.is_large() {
FileInfo::parse_large(&path)
} else {
FileInfo::parse_small(&path)
};

println!("{:#?}", file_info);
}
_ => unreachable!(),
}
}
Expand Down

0 comments on commit 90a9985

Please sign in to comment.