clippy
This commit is contained in:
parent
fd51599fa8
commit
fd36954477
20
src/bank.rs
20
src/bank.rs
|
@ -363,7 +363,7 @@ impl Bank {
|
||||||
let mut called_accounts: Vec<Account> = tx
|
let mut called_accounts: Vec<Account> = tx
|
||||||
.keys
|
.keys
|
||||||
.iter()
|
.iter()
|
||||||
.map(|key| accounts.get(key).cloned().unwrap_or(Account::default()))
|
.map(|key| accounts.get(key).cloned().unwrap_or_default())
|
||||||
.collect();
|
.collect();
|
||||||
// There is no way to predict what contract will execute without an error
|
// There is no way to predict what contract will execute without an error
|
||||||
// If a fee can pay for execution then the contract will be scheduled
|
// If a fee can pay for execution then the contract will be scheduled
|
||||||
|
@ -374,7 +374,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
fn load_accounts(
|
fn load_accounts(
|
||||||
&self,
|
&self,
|
||||||
txs: &Vec<Transaction>,
|
txs: &[Transaction],
|
||||||
accounts: &HashMap<Pubkey, Account>,
|
accounts: &HashMap<Pubkey, Account>,
|
||||||
error_counters: &mut ErrorCounters,
|
error_counters: &mut ErrorCounters,
|
||||||
) -> Vec<Result<Vec<Account>>> {
|
) -> Vec<Result<Vec<Account>>> {
|
||||||
|
@ -409,8 +409,8 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn store_accounts(
|
pub fn store_accounts(
|
||||||
res: &Vec<Result<Transaction>>,
|
res: &[Result<Transaction>],
|
||||||
loaded: &Vec<Result<Vec<Account>>>,
|
loaded: &[Result<Vec<Account>>],
|
||||||
accounts: &mut HashMap<Pubkey, Account>,
|
accounts: &mut HashMap<Pubkey, Account>,
|
||||||
) {
|
) {
|
||||||
loaded.iter().zip(res.iter()).for_each(|(racc, rtx)| {
|
loaded.iter().zip(res.iter()).for_each(|(racc, rtx)| {
|
||||||
|
@ -439,7 +439,7 @@ impl Bank {
|
||||||
let txs_len = txs.len();
|
let txs_len = txs.len();
|
||||||
let mut error_counters = ErrorCounters::default();
|
let mut error_counters = ErrorCounters::default();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let mut loaded_accounts = self.load_accounts(&txs, &mut accounts, &mut error_counters);
|
let mut loaded_accounts = self.load_accounts(&txs, &accounts, &mut error_counters);
|
||||||
let load_elapsed = now.elapsed();
|
let load_elapsed = now.elapsed();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let cur_tx_count = self.transaction_count.load(Ordering::Relaxed);
|
let cur_tx_count = self.transaction_count.load(Ordering::Relaxed);
|
||||||
if ((cur_tx_count + tx_count) & !(262144 - 1)) > cur_tx_count & !(262144 - 1) {
|
if ((cur_tx_count + tx_count) & !(262_144 - 1)) > cur_tx_count & !(262_144 - 1) {
|
||||||
info!("accounts.len: {}", accounts.len());
|
info!("accounts.len: {}", accounts.len());
|
||||||
}
|
}
|
||||||
self.transaction_count
|
self.transaction_count
|
||||||
|
@ -628,7 +628,7 @@ impl Bank {
|
||||||
/// will progress one step.
|
/// will progress one step.
|
||||||
fn apply_signature(from: Pubkey, signature: Signature, account: &mut [Account]) {
|
fn apply_signature(from: Pubkey, signature: Signature, account: &mut [Account]) {
|
||||||
let mut pending: HashMap<Signature, Plan> =
|
let mut pending: HashMap<Signature, Plan> =
|
||||||
deserialize(&account[1].userdata).unwrap_or(HashMap::new());
|
deserialize(&account[1].userdata).unwrap_or_default();
|
||||||
if let Occupied(mut e) = pending.entry(signature) {
|
if let Occupied(mut e) = pending.entry(signature) {
|
||||||
e.get_mut().apply_witness(&Witness::Signature, &from);
|
e.get_mut().apply_witness(&Witness::Signature, &from);
|
||||||
if let Some(payment) = e.get().final_payment() {
|
if let Some(payment) = e.get().final_payment() {
|
||||||
|
@ -651,13 +651,15 @@ impl Bank {
|
||||||
/// will progress one step.
|
/// will progress one step.
|
||||||
fn apply_timestamp(from: Pubkey, dt: DateTime<Utc>, account: &mut Account) {
|
fn apply_timestamp(from: Pubkey, dt: DateTime<Utc>, account: &mut Account) {
|
||||||
let mut pending: HashMap<Signature, Plan> =
|
let mut pending: HashMap<Signature, Plan> =
|
||||||
deserialize(&account.userdata).unwrap_or(HashMap::new());
|
deserialize(&account.userdata).unwrap_or_default();
|
||||||
|
//deserialize(&account.userdata).unwrap_or(HashMap::new());
|
||||||
|
|
||||||
// Check to see if any timelocked transactions can be completed.
|
// Check to see if any timelocked transactions can be completed.
|
||||||
let mut completed = vec![];
|
let mut completed = vec![];
|
||||||
|
|
||||||
// Hold 'pending' write lock until the end of this function. Otherwise another thread can
|
// Hold 'pending' write lock until the end of this function. Otherwise another thread can
|
||||||
// double-spend if it enters before the modified plan is removed from 'pending'.
|
// double-spend if it enters before the modified plan is removed from 'pending'.
|
||||||
for (key, plan) in pending.iter_mut() {
|
for (key, plan) in &mut pending {
|
||||||
plan.apply_witness(&Witness::Timestamp(dt), &from);
|
plan.apply_witness(&Witness::Timestamp(dt), &from);
|
||||||
if let Some(_payment) = plan.final_payment() {
|
if let Some(_payment) = plan.final_payment() {
|
||||||
completed.push(key.clone());
|
completed.push(key.clone());
|
||||||
|
|
|
@ -515,15 +515,13 @@ fn main() {
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if matches.is_present("reject-extra-nodes") {
|
if matches.is_present("reject-extra-nodes") && nodes.len() > num_nodes {
|
||||||
if nodes.len() > num_nodes {
|
|
||||||
println!(
|
println!(
|
||||||
"Error: Extra nodes discovered. Expecting exactly {}",
|
"Error: Extra nodes discovered. Expecting exactly {}",
|
||||||
num_nodes
|
num_nodes
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if leader.is_none() {
|
if leader.is_none() {
|
||||||
println!("no leader");
|
println!("no leader");
|
||||||
|
|
|
@ -293,7 +293,7 @@ impl Fullnode {
|
||||||
&crdt,
|
&crdt,
|
||||||
tick_duration,
|
tick_duration,
|
||||||
node.sockets.transaction,
|
node.sockets.transaction,
|
||||||
blob_recycler.clone(),
|
&blob_recycler,
|
||||||
exit.clone(),
|
exit.clone(),
|
||||||
ledger_path,
|
ledger_path,
|
||||||
sigverify_disabled,
|
sigverify_disabled,
|
||||||
|
|
|
@ -12,8 +12,7 @@ pub fn recv_mmsg(socket: &UdpSocket, packets: &mut [Packet]) -> io::Result<usize
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
socket.set_nonblocking(false)?;
|
socket.set_nonblocking(false)?;
|
||||||
let count = cmp::min(NUM_RCVMMSGS, packets.len());
|
let count = cmp::min(NUM_RCVMMSGS, packets.len());
|
||||||
for n in 0..count {
|
for p in packets.iter_mut().take(count) {
|
||||||
let p = &mut packets[n];
|
|
||||||
p.meta.size = 0;
|
p.meta.size = 0;
|
||||||
match socket.recv_from(&mut p.data) {
|
match socket.recv_from(&mut p.data) {
|
||||||
Err(_) if i > 0 => {
|
Err(_) if i > 0 => {
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl Tpu {
|
||||||
crdt: &Arc<RwLock<Crdt>>,
|
crdt: &Arc<RwLock<Crdt>>,
|
||||||
tick_duration: Option<Duration>,
|
tick_duration: Option<Duration>,
|
||||||
transactions_sockets: Vec<UdpSocket>,
|
transactions_sockets: Vec<UdpSocket>,
|
||||||
blob_recycler: BlobRecycler,
|
blob_recycler: &BlobRecycler,
|
||||||
exit: Arc<AtomicBool>,
|
exit: Arc<AtomicBool>,
|
||||||
ledger_path: &str,
|
ledger_path: &str,
|
||||||
sigverify_disabled: bool,
|
sigverify_disabled: bool,
|
||||||
|
|
|
@ -131,11 +131,11 @@ impl Transaction {
|
||||||
fn new_from_instruction(
|
fn new_from_instruction(
|
||||||
from_keypair: &Keypair,
|
from_keypair: &Keypair,
|
||||||
contract: Pubkey,
|
contract: Pubkey,
|
||||||
instruction: Instruction,
|
instruction: &Instruction,
|
||||||
last_id: Hash,
|
last_id: Hash,
|
||||||
fee: i64,
|
fee: i64,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let userdata = serialize(&instruction).unwrap();
|
let userdata = serialize(instruction).unwrap();
|
||||||
Self::new_with_userdata(from_keypair, &[contract], userdata, last_id, fee)
|
Self::new_with_userdata(from_keypair, &[contract], userdata, last_id, fee)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ impl Transaction {
|
||||||
let budget = Budget::Pay(payment);
|
let budget = Budget::Pay(payment);
|
||||||
let plan = Plan::Budget(budget);
|
let plan = Plan::Budget(budget);
|
||||||
let instruction = Instruction::NewContract(Contract { plan, tokens });
|
let instruction = Instruction::NewContract(Contract { plan, tokens });
|
||||||
Self::new_from_instruction(from_keypair, contract, instruction, last_id, fee)
|
Self::new_from_instruction(from_keypair, contract, &instruction, last_id, fee)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create and sign a new Transaction. Used for unit-testing.
|
/// Create and sign a new Transaction. Used for unit-testing.
|
||||||
|
@ -170,7 +170,7 @@ impl Transaction {
|
||||||
last_id: Hash,
|
last_id: Hash,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let instruction = Instruction::ApplyTimestamp(dt);
|
let instruction = Instruction::ApplyTimestamp(dt);
|
||||||
Self::new_from_instruction(from_keypair, contract, instruction, last_id, 0)
|
Self::new_from_instruction(from_keypair, contract, &instruction, last_id, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create and sign a new Witness Signature. Used for unit-testing.
|
/// Create and sign a new Witness Signature. Used for unit-testing.
|
||||||
|
@ -181,7 +181,7 @@ impl Transaction {
|
||||||
last_id: Hash,
|
last_id: Hash,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let instruction = Instruction::ApplySignature(signature);
|
let instruction = Instruction::ApplySignature(signature);
|
||||||
Self::new_from_instruction(from_keypair, contract, instruction, last_id, 0)
|
Self::new_from_instruction(from_keypair, contract, &instruction, last_id, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_vote(from_keypair: &Keypair, vote: Vote, last_id: Hash, fee: i64) -> Self {
|
pub fn new_vote(from_keypair: &Keypair, vote: Vote, last_id: Hash, fee: i64) -> Self {
|
||||||
|
|
Loading…
Reference in New Issue