clippy fixups
This commit is contained in:
parent
b033e1d904
commit
546a1e90d5
|
@ -56,24 +56,20 @@ fn main() {
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("print", _) => {
|
("print", _) => {
|
||||||
let mut i = 0;
|
for (i, entry) in entries.enumerate() {
|
||||||
for entry in entries {
|
|
||||||
if i >= head {
|
if i >= head {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i += 1;
|
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
println!("{:?}", entry);
|
println!("{:?}", entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
("json", _) => {
|
("json", _) => {
|
||||||
let mut i = 0;
|
|
||||||
stdout().write_all(b"{\"ledger\":[\n").expect("open array");
|
stdout().write_all(b"{\"ledger\":[\n").expect("open array");
|
||||||
for entry in entries {
|
for (i, entry) in entries.enumerate() {
|
||||||
if i >= head {
|
if i >= head {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i += 1;
|
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
serde_json::to_writer(stdout(), &entry).expect("serialize");
|
serde_json::to_writer(stdout(), &entry).expect("serialize");
|
||||||
stdout().write_all(b",\n").expect("newline");
|
stdout().write_all(b",\n").expect("newline");
|
||||||
|
@ -84,10 +80,10 @@ fn main() {
|
||||||
let bank = Bank::default();
|
let bank = Bank::default();
|
||||||
if head != <usize>::max_value() {
|
if head != <usize>::max_value() {
|
||||||
let entries = entries.map(|entry| entry.unwrap()).take(head);
|
let entries = entries.map(|entry| entry.unwrap()).take(head);
|
||||||
bank.process_ledger(entries).expect("process_ledger").0;
|
bank.process_ledger(entries).expect("process_ledger");
|
||||||
} else {
|
} else {
|
||||||
let entries = entries.map(|entry| entry.unwrap());
|
let entries = entries.map(|entry| entry.unwrap());
|
||||||
bank.process_ledger(entries).expect("process_ledger").0;
|
bank.process_ledger(entries).expect("process_ledger");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
("verify-internal", _) => {
|
("verify-internal", _) => {
|
||||||
|
|
|
@ -469,13 +469,13 @@ pub fn next_entries_mut(
|
||||||
if transactions.is_empty() || transactions.len() == 1 {
|
if transactions.is_empty() || transactions.len() == 1 {
|
||||||
vec![Entry::new_mut(start_hash, num_hashes, transactions, false)]
|
vec![Entry::new_mut(start_hash, num_hashes, transactions, false)]
|
||||||
} else {
|
} else {
|
||||||
let mut start = 0;
|
let mut chunk_start = 0;
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
|
|
||||||
while start < transactions.len() {
|
while chunk_start < transactions.len() {
|
||||||
let mut chunk_end = transactions.len();
|
let mut chunk_end = transactions.len();
|
||||||
let mut upper = chunk_end;
|
let mut upper = chunk_end;
|
||||||
let mut lower = start;
|
let mut lower = chunk_start;
|
||||||
let mut next = chunk_end; // be optimistic that all will fit
|
let mut next = chunk_end; // be optimistic that all will fit
|
||||||
|
|
||||||
// binary search for how many transactions will fit in an Entry (i.e. a BLOB)
|
// binary search for how many transactions will fit in an Entry (i.e. a BLOB)
|
||||||
|
@ -488,7 +488,7 @@ pub fn next_entries_mut(
|
||||||
next,
|
next,
|
||||||
transactions.len()
|
transactions.len()
|
||||||
);
|
);
|
||||||
if Entry::will_fit(transactions[start..chunk_end].to_vec()) {
|
if Entry::will_fit(transactions[chunk_start..chunk_end].to_vec()) {
|
||||||
next = (upper + chunk_end) / 2;
|
next = (upper + chunk_end) / 2;
|
||||||
lower = chunk_end;
|
lower = chunk_end;
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -510,10 +510,10 @@ pub fn next_entries_mut(
|
||||||
entries.push(Entry::new_mut(
|
entries.push(Entry::new_mut(
|
||||||
start_hash,
|
start_hash,
|
||||||
num_hashes,
|
num_hashes,
|
||||||
transactions[start..chunk_end].to_vec(),
|
transactions[chunk_start..chunk_end].to_vec(),
|
||||||
transactions.len() - chunk_end > 0,
|
transactions.len() - chunk_end > 0,
|
||||||
));
|
));
|
||||||
start = chunk_end;
|
chunk_start = chunk_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
entries
|
entries
|
||||||
|
|
Loading…
Reference in New Issue