Skip to content

Commit

Permalink
Reformat imports to a consistent style for imports
Browse files Browse the repository at this point in the history
rustfmt.toml configuration:
  imports_granularity = "One"
  group_imports = "One"
  • Loading branch information
mvines committed Dec 3, 2021
1 parent 0ef1b25 commit b8837c0
Show file tree
Hide file tree
Showing 397 changed files with 5,990 additions and 5,175 deletions.
12 changes: 8 additions & 4 deletions account-decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ pub mod validator_info;
use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
solana_sdk::{
account::ReadableAccount, account::WritableAccount, clock::Epoch,
fee_calculator::FeeCalculator, pubkey::Pubkey,
account::{ReadableAccount, WritableAccount},
clock::Epoch,
fee_calculator::FeeCalculator,
pubkey::Pubkey,
},
std::{
io::{Read, Write},
Expand Down Expand Up @@ -202,8 +204,10 @@ fn slice_data(data: &[u8], data_slice_config: Option<UiDataSliceConfig>) -> &[u8

#[cfg(test)]
mod test {
use super::*;
use solana_sdk::account::{Account, AccountSharedData};
use {
super::*,
solana_sdk::account::{Account, AccountSharedData},
};

#[test]
fn test_slice_data() {
Expand Down
40 changes: 22 additions & 18 deletions account-decoder/src/parse_account_data.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use crate::{
parse_bpf_loader::parse_bpf_upgradeable_loader,
parse_config::parse_config,
parse_nonce::parse_nonce,
parse_stake::parse_stake,
parse_sysvar::parse_sysvar,
parse_token::{parse_token, spl_token_id},
parse_vote::parse_vote,
use {
crate::{
parse_bpf_loader::parse_bpf_upgradeable_loader,
parse_config::parse_config,
parse_nonce::parse_nonce,
parse_stake::parse_stake,
parse_sysvar::parse_sysvar,
parse_token::{parse_token, spl_token_id},
parse_vote::parse_vote,
},
inflector::Inflector,
serde_json::Value,
solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar},
std::collections::HashMap,
thiserror::Error,
};
use inflector::Inflector;
use serde_json::Value;
use solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar};
use std::collections::HashMap;
use thiserror::Error;

lazy_static! {
static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id();
Expand Down Expand Up @@ -112,12 +114,14 @@ pub fn parse_account_data(

#[cfg(test)]
mod test {
use super::*;
use solana_sdk::nonce::{
state::{Data, Versions},
State,
use {
super::*,
solana_sdk::nonce::{
state::{Data, Versions},
State,
},
solana_vote_program::vote_state::{VoteState, VoteStateVersions},
};
use solana_vote_program::vote_state::{VoteState, VoteStateVersions};

#[test]
fn test_parse_account_data() {
Expand Down
16 changes: 8 additions & 8 deletions account-decoder/src/parse_bpf_loader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
UiAccountData, UiAccountEncoding,
use {
crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
UiAccountData, UiAccountEncoding,
},
bincode::{deserialize, serialized_size},
solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey},
};
use bincode::{deserialize, serialized_size};
use solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey};

pub fn parse_bpf_upgradeable_loader(
data: &[u8],
Expand Down Expand Up @@ -90,9 +92,7 @@ pub struct UiProgramData {

#[cfg(test)]
mod test {
use super::*;
use bincode::serialize;
use solana_sdk::pubkey::Pubkey;
use {super::*, bincode::serialize, solana_sdk::pubkey::Pubkey};

#[test]
fn test_parse_bpf_upgradeable_loader_accounts() {
Expand Down
29 changes: 16 additions & 13 deletions account-decoder/src/parse_config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
validator_info,
use {
crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
validator_info,
},
bincode::deserialize,
serde_json::Value,
solana_config_program::{get_config_data, ConfigKeys},
solana_sdk::{
pubkey::Pubkey,
stake::config::{self as stake_config, Config as StakeConfig},
},
};
use bincode::deserialize;
use serde_json::Value;
use solana_config_program::{get_config_data, ConfigKeys};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::stake::config::{self as stake_config, Config as StakeConfig};

pub fn parse_config(data: &[u8], pubkey: &Pubkey) -> Result<ConfigAccountType, ParseAccountError> {
let parsed_account = if pubkey == &stake_config::id() {
Expand Down Expand Up @@ -87,11 +91,10 @@ pub struct UiConfig<T> {

#[cfg(test)]
mod test {
use super::*;
use crate::validator_info::ValidatorInfo;
use serde_json::json;
use solana_config_program::create_config_account;
use solana_sdk::account::ReadableAccount;
use {
super::*, crate::validator_info::ValidatorInfo, serde_json::json,
solana_config_program::create_config_account, solana_sdk::account::ReadableAccount,
};

#[test]
fn test_parse_config() {
Expand Down
26 changes: 15 additions & 11 deletions account-decoder/src/parse_nonce.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{parse_account_data::ParseAccountError, UiFeeCalculator};
use solana_sdk::{
instruction::InstructionError,
nonce::{state::Versions, State},
use {
crate::{parse_account_data::ParseAccountError, UiFeeCalculator},
solana_sdk::{
instruction::InstructionError,
nonce::{state::Versions, State},
},
};

pub fn parse_nonce(data: &[u8]) -> Result<UiNonceState, ParseAccountError> {
Expand Down Expand Up @@ -42,14 +44,16 @@ pub struct UiNonceData {

#[cfg(test)]
mod test {
use super::*;
use solana_sdk::{
hash::Hash,
nonce::{
state::{Data, Versions},
State,
use {
super::*,
solana_sdk::{
hash::Hash,
nonce::{
state::{Data, Versions},
State,
},
pubkey::Pubkey,
},
pubkey::Pubkey,
};

#[test]
Expand Down
19 changes: 11 additions & 8 deletions account-decoder/src/parse_stake.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount,
use {
crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount,
},
bincode::deserialize,
solana_sdk::{
clock::{Epoch, UnixTimestamp},
stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState},
},
};
use bincode::deserialize;
use solana_sdk::clock::{Epoch, UnixTimestamp};
use solana_sdk::stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState};

pub fn parse_stake(data: &[u8]) -> Result<StakeAccountType, ParseAccountError> {
let stake_state: StakeState = deserialize(data)
Expand Down Expand Up @@ -132,8 +136,7 @@ impl From<Delegation> for UiDelegation {

#[cfg(test)]
mod test {
use super::*;
use bincode::serialize;
use {super::*, bincode::serialize};

#[test]
fn test_parse_stake() {
Expand Down
38 changes: 21 additions & 17 deletions account-decoder/src/parse_sysvar.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount, UiFeeCalculator,
};
use bincode::deserialize;
use bv::BitVec;
#[allow(deprecated)]
use solana_sdk::sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes};
use solana_sdk::{
clock::{Clock, Epoch, Slot, UnixTimestamp},
epoch_schedule::EpochSchedule,
pubkey::Pubkey,
rent::Rent,
slot_hashes::SlotHashes,
slot_history::{self, SlotHistory},
stake_history::{StakeHistory, StakeHistoryEntry},
sysvar::{self, rewards::Rewards},
use {
crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount, UiFeeCalculator,
},
bincode::deserialize,
bv::BitVec,
solana_sdk::{
clock::{Clock, Epoch, Slot, UnixTimestamp},
epoch_schedule::EpochSchedule,
pubkey::Pubkey,
rent::Rent,
slot_hashes::SlotHashes,
slot_history::{self, SlotHistory},
stake_history::{StakeHistory, StakeHistoryEntry},
sysvar::{self, rewards::Rewards},
},
};

pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
Expand Down Expand Up @@ -218,10 +220,12 @@ pub struct UiStakeHistoryEntry {

#[cfg(test)]
mod test {
use super::*;
#[allow(deprecated)]
use solana_sdk::sysvar::recent_blockhashes::IterItem;
use solana_sdk::{account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash};
use {
super::*,
solana_sdk::{account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash},
};

#[test]
fn test_parse_sysvars() {
Expand Down
22 changes: 12 additions & 10 deletions account-decoder/src/parse_token.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount, StringDecimals,
};
use solana_sdk::pubkey::Pubkey;
use spl_token::{
solana_program::{
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
use {
crate::{
parse_account_data::{ParsableAccount, ParseAccountError},
StringAmount, StringDecimals,
},
solana_sdk::pubkey::Pubkey,
spl_token::{
solana_program::{
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
},
state::{Account, AccountState, Mint, Multisig},
},
state::{Account, AccountState, Mint, Multisig},
std::str::FromStr,
};
use std::str::FromStr;

// A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to
// solana_sdk::pubkey::Pubkey
Expand Down
15 changes: 8 additions & 7 deletions account-decoder/src/parse_vote.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::{parse_account_data::ParseAccountError, StringAmount};
use solana_sdk::{
clock::{Epoch, Slot},
pubkey::Pubkey,
use {
crate::{parse_account_data::ParseAccountError, StringAmount},
solana_sdk::{
clock::{Epoch, Slot},
pubkey::Pubkey,
},
solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState},
};
use solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState};

pub fn parse_vote(data: &[u8]) -> Result<VoteAccountType, ParseAccountError> {
let mut vote_state = VoteState::deserialize(data).map_err(ParseAccountError::from)?;
Expand Down Expand Up @@ -121,8 +123,7 @@ struct UiEpochCredits {

#[cfg(test)]
mod test {
use super::*;
use solana_vote_program::vote_state::VoteStateVersions;
use {super::*, solana_vote_program::vote_state::VoteStateVersions};

#[test]
fn test_parse_vote() {
Expand Down
22 changes: 12 additions & 10 deletions accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#![allow(clippy::integer_arithmetic)]
#[macro_use]
extern crate log;
use clap::{crate_description, crate_name, value_t, App, Arg};
use rayon::prelude::*;
use solana_measure::measure::Measure;
use solana_runtime::{
accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts_db::AccountShrinkThreshold,
accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors,
use {
clap::{crate_description, crate_name, value_t, App, Arg},
rayon::prelude::*,
solana_measure::measure::Measure,
solana_runtime::{
accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts_db::AccountShrinkThreshold,
accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors,
},
solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey},
std::{env, fs, path::PathBuf},
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
use std::{env, fs, path::PathBuf};

fn main() {
solana_logger::setup();
Expand Down
Loading

0 comments on commit b8837c0

Please sign in to comment.