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

feat: ckb init use secp256k1 as default ba-code-hash #1023

Merged
merged 1 commit into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions ckb-bin/src/subcommand/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
}

let runner = Runner::default().to_string();
let block_assembler = match args.block_assembler_code_hash {
let default_hash = format!("{:#x}", CODE_HASH_SECP256K1_BLAKE160_SIGHASH_ALL);
let block_assembler_code_hash = args.block_assembler_code_hash.as_ref().or_else(|| {
if !args.block_assembler_args.is_empty() {
Some(&default_hash)
} else {
None
}
});

let block_assembler = match block_assembler_code_hash {
Some(hash) => {
let default_hash = format!("{:#x}", CODE_HASH_SECP256K1_BLAKE160_SIGHASH_ALL);
if default_hash != hash {
if default_hash != *hash {
eprintln!(
"WARN: the default secp256k1 code hash is `{}`, you are using `{}`",
default_hash, hash
Expand Down
7 changes: 5 additions & 2 deletions util/app-config/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,18 @@ fn init() -> App<'static, 'static> {
.long(ARG_BA_CODE_HASH)
.value_name("code_hash")
.takes_value(true)
.help("Set code_hash in [block_assembler]"),
.help(
"Sets code_hash in [block_assembler] \
[default: secp256k1 if --ba-arg is present]",
),
)
.arg(
Arg::with_name(ARG_BA_ARG)
.long(ARG_BA_ARG)
.value_name("arg")
.multiple(true)
.number_of_values(1)
.help("Set args in [block_assembler]"),
.help("Sets args in [block_assembler]"),
)
.arg(
Arg::with_name("export-specs")
Expand Down