Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Make clippy even happier.
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe committed Apr 30, 2024
1 parent 97d93d5 commit e3d7cf4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions arbitrator/bench/src/parse_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ impl FileData {
let mut line = String::new();
while reader.read_line(&mut line)? > 0 {
if line.starts_with("Id:") {
id = line.split(":").nth(1).unwrap().trim().parse().unwrap();
id = line.split(':').nth(1).unwrap().trim().parse().unwrap();
} else if line.starts_with("HasDelayedMsg:") {
has_delayed_msg = line.split(":").nth(1).unwrap().trim().parse().unwrap();
has_delayed_msg = line.split(':').nth(1).unwrap().trim().parse().unwrap();
} else if line.starts_with("DelayedMsgNr:") {
delayed_msg_nr = line.split(":").nth(1).unwrap().trim().parse().unwrap();
delayed_msg_nr = line.split(':').nth(1).unwrap().trim().parse().unwrap();
} else if line.starts_with("Preimages:") {
items.push(Item::from_reader(&mut reader, &mut line)?);
} else if line.starts_with("BatchInfo:") {
let parts: Vec<_> = line.split(",").collect();
batch_info.number = parts[0].split(":").nth(2).unwrap().trim().parse().unwrap();
batch_info.data = hex::decode(parts[1].split(":").nth(1).unwrap().trim()).unwrap();
let parts: Vec<_> = line.split(',').collect();
batch_info.number = parts[0].split(':').nth(2).unwrap().trim().parse().unwrap();
batch_info.data = hex::decode(parts[1].split(':').nth(1).unwrap().trim()).unwrap();
} else if line.starts_with("DelayedMsg:") {
delayed_msg = hex::decode(line.split(":").nth(1).unwrap().trim()).unwrap();
delayed_msg = hex::decode(line.split(':').nth(1).unwrap().trim()).unwrap();
} else if line.starts_with("StartState:") {
let parts: Vec<_> = line.split(",").collect();
let parts: Vec<_> = line.split(',').collect();

// Parsing block_hash
let block_hash_str = parts[0].split("BlockHash:").nth(1).unwrap().trim();
start_state.block_hash =
hex::decode(block_hash_str.strip_prefix("0x").unwrap()).unwrap();

// Parsing send_root
let send_root_str = parts[1].split(":").nth(1).unwrap().trim();
let send_root_str = parts[1].split(':').nth(1).unwrap().trim();
start_state.send_root =
hex::decode(send_root_str.strip_prefix("0x").unwrap()).unwrap();

// Parsing batch
start_state.batch = parts[2]
.split(":")
.split(':')
.nth(1)
.unwrap()
.trim()
Expand All @@ -95,7 +95,7 @@ impl FileData {

// Parsing pos_in_batch
start_state.pos_in_batch = parts[3]
.split(":")
.split(':')
.nth(1)
.unwrap()
.trim()
Expand Down Expand Up @@ -131,20 +131,20 @@ impl Item {
}
if line.starts_with("Preimages:") {
line.clear();
while reader.read_line(line)? > 0 && line.starts_with("\t") {
let parts: Vec<_> = line.trim().split(",").collect();
let type_ = parts[0].split(":").nth(1).unwrap().trim().parse().unwrap();
while reader.read_line(line)? > 0 && line.starts_with('\t') {
let parts: Vec<_> = line.trim().split(',').collect();
let type_ = parts[0].split(':').nth(1).unwrap().trim().parse().unwrap();
let hash = hex::decode(
parts[1]
.split(":")
.split(':')
.nth(1)
.unwrap()
.trim()
.strip_prefix("0x")
.unwrap(),
)
.unwrap();
let data = hex::decode(parts[2].split(":").nth(1).unwrap().trim()).unwrap();
let data = hex::decode(parts[2].split(':').nth(1).unwrap().trim()).unwrap();
preimages.push(Preimage { type_, hash, data });
line.clear();
}
Expand Down
4 changes: 2 additions & 2 deletions arbitrator/bench/src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub fn prepare_machine(
machines: PathBuf,
always_merkleize: bool,
) -> eyre::Result<Machine> {
let file = File::open(&preimages)?;
let file = File::open(preimages)?;
let reader = BufReader::new(file);

let data = FileData::from_reader(reader)?;
let item = data.items.get(0).unwrap().clone();
let item = data.items.first().unwrap().clone();
let preimages = item.preimages;
let preimages = preimages
.into_iter()
Expand Down

0 comments on commit e3d7cf4

Please sign in to comment.