Merge pull request #1 from KirillLykov/format_cargo_fmt

apply cargo fmt
This commit is contained in:
galactus 2022-11-02 14:41:23 +00:00 committed by GitHub
commit 0c63088b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 49 deletions

View File

@ -33,10 +33,10 @@ impl Default for Config {
quotes_per_second: 1,
account_keys: String::new(),
mango_keys: String::new(),
transaction_save_file : String::new(),
block_data_save_file : String::new(),
airdrop_accounts : false,
mango_cluster : "testnet.0".to_string(),
transaction_save_file: String::new(),
block_data_save_file: String::new(),
airdrop_accounts: false,
mango_cluster: "testnet.0".to_string(),
}
}
}
@ -136,29 +136,29 @@ pub fn build_args<'a, 'b>(version: &'b str) -> App<'a, 'b> {
)
.arg(
Arg::with_name("transaction_save_file")
.short("tsf")
.long("transaction_save_file")
.value_name("FILENAME")
.takes_value(true)
.required(false)
.help("To save details of all transactions during a run")
.short("tsf")
.long("transaction_save_file")
.value_name("FILENAME")
.takes_value(true)
.required(false)
.help("To save details of all transactions during a run"),
)
.arg(
Arg::with_name("block_data_save_file")
.short("bdsf")
.long("block_data_save_file")
.value_name("FILENAME")
.takes_value(true)
.required(false)
.help("To save details of all block containing mm transactions")
.short("bdsf")
.long("block_data_save_file")
.value_name("FILENAME")
.takes_value(true)
.required(false)
.help("To save details of all block containing mm transactions"),
)
.arg(
Arg::with_name("airdrop-accounts")
.long("airdrop-accounts")
.value_name("BOOL")
.takes_value(false)
.required(false)
.help("Airdrop all MM accounts before stating")
.long("airdrop-accounts")
.value_name("BOOL")
.takes_value(false)
.required(false)
.help("Airdrop all MM accounts before stating"),
)
.arg(
Arg::with_name("mango-cluster")
@ -235,12 +235,11 @@ pub fn extract_args(matches: &ArgMatches) -> Config {
Some(x) => x.to_string(),
None => String::new(),
};
args.airdrop_accounts = matches.is_present("airdrop-accounts");
args.mango_cluster = match matches.value_of("mango-cluster") {
Some(x) => x.to_string(),
None => "testnet.0".to_string(),
};
args
}

View File

@ -42,7 +42,7 @@ use std::{
collections::HashMap,
collections::{HashSet, VecDeque},
fs,
ops::{Div, Mul, Add},
ops::{Add, Div, Mul},
str::FromStr,
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
@ -343,7 +343,7 @@ fn process_signature_confirmation_batch(
successful: s.err.is_none(),
error: match &s.err {
Some(e) => e.to_string(),
None=> "".to_string(),
None => "".to_string(),
},
block_hash: Pubkey::default().to_string(),
slot_leader: Pubkey::default().to_string(),
@ -496,7 +496,7 @@ struct BlockData {
pub total_transactions: u64,
pub number_of_mm_transactions: u64,
pub block_time: u64,
pub cu_consumed : u64,
pub cu_consumed: u64,
}
fn confirmations_by_blocks(
@ -599,7 +599,6 @@ fn confirmations_by_blocks(
Some(x) => x,
None => continue,
};
let mut mm_transaction_count: u64 = 0;
let rewards = &block.rewards.unwrap();
let slot_leader = match rewards
@ -635,7 +634,6 @@ fn confirmations_by_blocks(
};
// add CU in counter
if let Some(meta) = &meta {
match meta.compute_units_consumed {
solana_transaction_status::option_serializer::OptionSerializer::Some(x) => {
cu_consumed = cu_consumed.saturating_add(x);
@ -736,8 +734,8 @@ fn write_transaction_data_into_csv(
let timeout_lk = tx_timeout_records.read().unwrap();
for timeout_record in timeout_lk.iter() {
writer.serialize(
TransactionConfirmRecord{
writer
.serialize(TransactionConfirmRecord {
block_hash: "".to_string(),
confirmed_at: "".to_string(),
confirmed_slot: 0,
@ -751,18 +749,14 @@ fn write_transaction_data_into_csv(
slot_processed: 0,
successful: false,
timed_out: true,
}
).unwrap();
})
.unwrap();
}
}
writer.flush().unwrap();
}
fn write_block_data_into_csv(
block_data_csv: String,
tx_block_data: Arc<RwLock<Vec<BlockData>>>,
) {
fn write_block_data_into_csv(block_data_csv: String, tx_block_data: Arc<RwLock<Vec<BlockData>>>) {
if block_data_csv.is_empty() {
return;
}
@ -775,7 +769,6 @@ fn write_block_data_into_csv(
writer.flush().unwrap();
}
fn main() {
solana_logger::setup_with_default("solana=info");
solana_metrics::set_panic_hook("bench-mango", /*version:*/ None);
@ -948,17 +941,20 @@ fn main() {
if airdrop_accounts {
println!("Transfering 1 SOL to {}", mango_account_signer.pubkey());
let inx = solana_sdk::system_instruction::transfer( &id.pubkey(), &mango_account_signer.pubkey(), LAMPORTS_PER_SOL);
let inx = solana_sdk::system_instruction::transfer(
&id.pubkey(),
&mango_account_signer.pubkey(),
LAMPORTS_PER_SOL,
);
let mut tx = Transaction::new_unsigned(Message::new(&[inx], Some(&id.pubkey())));
let mut tx = Transaction::new_unsigned(Message::new(
&[inx],
Some(&id.pubkey()),
));
if let Ok(recent_blockhash) = blockhash.read() {
tx.sign(&[id], *recent_blockhash);
}
rpc_client.send_and_confirm_transaction_with_spinner(&tx).unwrap();
rpc_client
.send_and_confirm_transaction_with_spinner(&tx)
.unwrap();
}
info!(
@ -1086,10 +1082,7 @@ fn main() {
tx_timeout_records,
);
write_block_data_into_csv(
block_data_save_file,
tx_block_data
);
write_block_data_into_csv(block_data_save_file, tx_block_data);
})
.unwrap();