Skip to content

Commit

Permalink
clippy, format, other nits
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-solana committed Jan 25, 2019
1 parent c0bc83b commit d2e41fe
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn main() {
);
exit(1);
}
let bank = Bank::new_with_builtin_programs();
let bank = Bank::default();
{
let genesis = entries.by_ref().take(NUM_GENESIS_ENTRIES);
if let Err(e) = bank.process_ledger(genesis) {
Expand Down Expand Up @@ -139,7 +139,7 @@ fn main() {
last_id = entry.id;
num_entries += 1;

if let Err(e) = bank.process_entry(&entry) {
if let Err(e) = bank.process_entries(&[entry]) {
eprintln!("verify failed at entry[{}], err: {:?}", i + 2, e);
if !matches.is_present("continue") {
exit(1);
Expand Down
5 changes: 1 addition & 4 deletions src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ impl AccountsDB {
self.transaction_count
}
pub fn account_values_slow(&self) -> Vec<(Pubkey, solana_sdk::account::Account)> {
self.accounts
.iter()
.map(|(x, y)| (x.clone(), y.clone()))
.collect()
self.accounts.iter().map(|(x, y)| (*x, y.clone())).collect()
}
fn merge(&mut self, other: Self) {
self.transaction_count += other.transaction_count;
Expand Down
6 changes: 3 additions & 3 deletions src/bank_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::accounts::{Accounts, ErrorCounters, InstructionAccounts, InstructionLoaders};
use crate::bank::{BankError, Result};
use crate::counter::Counter;
use solana_sdk::native_program::ProgramError;
use crate::entry::Entry;
use crate::last_id_queue::{LastIdQueue, MAX_ENTRY_IDS};
use crate::leader_scheduler::TICKS_PER_BLOCK;
Expand Down Expand Up @@ -482,7 +481,7 @@ impl BankState {
_ => result,
})
.collect()
}
}
pub fn par_execute_entries(&self, entries: &[(&Entry, Vec<Result<()>>)]) -> Result<()> {
let head = &self.checkpoints[0];
inc_new_counter_info!("bank-par_execute_entries-count", entries.len());
Expand Down Expand Up @@ -608,6 +607,7 @@ impl BankState {
#[cfg(test)]
mod test {
use super::*;
use solana_sdk::native_program::ProgramError;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::KeypairUtil;
use solana_sdk::system_program;
Expand Down Expand Up @@ -707,7 +707,7 @@ mod test {
let updated_results = BankState::ignore_program_errors(results);
assert_ne!(updated_results, expected_results);
}

//#[test]
//fn test_bank_record_transactions() {
// let mint = Mint::new(10_000);
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<T: Clone> Checkpoints<T> {
let (data, prev) = self.load(trunk).expect("load from inverse").clone();
new.store(trunk, data.clone(), prev);
if let Some(children) = inverse.get(&trunk) {
let mut next = children.into_iter().map(|x| *x).collect();
let mut next = children.into_iter().cloned().collect();
queue.append(&mut next);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ impl Forks {
return Err(BankError::InvalidTrunk);
}
let len = states.len();
let old_trunk = states[len - 1].clone();
let new_trunk = states[len - 2].clone();
let old_trunk = states[len - 1];
let new_trunk = states[len - 2];
if !new_trunk.1.finalized() {
println!("new_trunk id {}", new_trunk.1.fork_id());
return Err(BankError::CheckpointNotFinalized);
Expand Down
4 changes: 2 additions & 2 deletions src/last_id_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ impl LastIdQueue {
pub fn fork(&self) -> Self {
Self {
entries: self.entries.clone(),
tick_height: self.tick_height.clone(),
last_id: self.last_id.clone(),
tick_height: self.tick_height,
last_id: self.last_id,
}
}
/// merge for entryq is a swap
Expand Down
14 changes: 7 additions & 7 deletions src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ impl ReplayStage {
// vote(options.last());

if end_block != start_block {
if let Some(signer) = vote_signer {
if let Some(sender) = vote_blob_sender {
signer
.send_validator_vote(bank, &cluster_info, sender)
.unwrap();
}
}
if let Some(signer) = vote_signer {
if let Some(sender) = vote_blob_sender {
signer
.send_validator_vote(bank, &cluster_info, sender)
.unwrap();
}
}
}
let (scheduled_leader, _) = bank
.get_current_leader()
Expand Down
9 changes: 3 additions & 6 deletions src/status_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ pub struct StatusCache {

impl StatusCache {
pub fn new(last_id: &Hash) -> Self {
let keys = (0..27)
.into_iter()
.map(|i| last_id.hash_at_index(i))
.collect();
let keys = (0..27).map(|i| last_id.hash_at_index(i)).collect();
Self {
signatures: Bloom::new(38340234, keys),
signatures: Bloom::new(38_340_234, keys),
failures: HashMap::new(),
merges: VecDeque::new(),
}
Expand All @@ -38,7 +35,7 @@ impl StatusCache {
return true;
}
}
return false;
false
}
/// test if a signature is known
pub fn has_signature(&self, sig: &Signature) -> bool {
Expand Down

0 comments on commit d2e41fe

Please sign in to comment.