Skip to content

Commit

Permalink
Remove faster-hex (nervosnetwork#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson authored Nov 17, 2023
1 parent a833a1e commit ab3db71
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
20 changes: 6 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ckb-debugger-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ckb-mock-tx-types = { path = "../ckb-mock-tx-types", version="0.111.0" }
ckb-script = { version = "=0.111.0", default-features = false }
ckb-types = "=0.111.0"
ckb-vm = "=0.24.6"
faster-hex = "0.4.0"
hex = "0.4"
js-sys = "0.3.27"
regex = "1"
Expand Down
6 changes: 2 additions & 4 deletions ckb-debugger-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use ckb_types::{
prelude::*,
H256,
};
use faster_hex::hex_decode_fallback;
use serde::{Deserialize, Serialize};
use serde_json::{from_str as from_json_str, to_string as to_json_string};
use serde_plain::from_str as from_plain_str;
Expand Down Expand Up @@ -98,9 +97,8 @@ fn internal_run_json(
if hex_script_hash.len() != 66 || (!hex_script_hash.starts_with("0x")) {
return Err("Invalid script hash format!".to_string());
}
let mut b = [0u8; 32];
hex_decode_fallback(&hex_script_hash.as_bytes()[2..], &mut b[..]);
let script_hash = Byte32::new(b);
let b = hex::decode(&hex_script_hash.as_bytes()[2..]).map_err(|e| e.to_string())?;
let script_hash = Byte32::from_slice(b.as_slice()).map_err(|e| e.to_string())?;
let max_cycle: Cycle = max_cycle.parse().map_err(|_| "Invalid max cycle!".to_string())?;
run(&mock_tx, &script_group_type, &script_hash, max_cycle, debug_printer)
}
Expand Down
1 change: 0 additions & 1 deletion ckb-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ckb-vm = { version = "=0.24.6" }
ckb-vm-debug-utils = { path = "../ckb-vm-debug-utils", version="0.111.0" }
ckb-vm-pprof = { path = "../ckb-vm-pprof", version="0.111.0" }
env_logger = "0.4.3"
faster-hex = "0.4.0"
ckb-gdb-remote-protocol = { path = "../ckb-gdb-remote-protocol", version="0.111.0" }
gdbstub = "0.6.6"
gdbstub_arch = "0.2.4"
Expand Down
7 changes: 3 additions & 4 deletions ckb-debugger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use ckb_script::{
use ckb_types::core::cell::resolve_transaction;
use ckb_types::core::HeaderView;
use ckb_types::packed::Byte32;
use ckb_types::prelude::Entity;
use ckb_vm::cost_model::estimate_cycles;
use ckb_vm::decoder::build_decoder;
use ckb_vm::error::Error;
Expand All @@ -27,7 +28,6 @@ use ckb_vm_debug_utils::ElfDumper;
use ckb_vm_debug_utils::Stdio;
use ckb_vm_pprof::{PProfMachine, Profile};
use clap::{crate_version, App, Arg};
use faster_hex::hex_decode_fallback;
use serde_json::from_str as from_json_str;
use serde_plain::from_str as from_plain_str;
use std::fs::{read, read_to_string};
Expand Down Expand Up @@ -241,9 +241,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if hex_script_hash.len() != 66 || (!hex_script_hash.starts_with("0x")) {
panic!("Invalid script hash format!");
}
let mut b = [0u8; 32];
hex_decode_fallback(&hex_script_hash.as_bytes()[2..], &mut b[..]);
Byte32::new(b)
let b = hex::decode(&hex_script_hash.as_bytes()[2..])?;
Byte32::from_slice(b.as_slice())?
} else {
let mut cell_type = matches_cell_type;
let mut cell_index = matches_cell_index;
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_width = 120
chain_width = 119
chain_width = 120

0 comments on commit ab3db71

Please sign in to comment.