owner -> owner() (#16782)
This commit is contained in:
parent
1a4a7059af
commit
ca14c18998
|
@ -2,7 +2,7 @@ use solana_runtime::{
|
||||||
accounts_index::{AccountIndex, IndexKey},
|
accounts_index::{AccountIndex, IndexKey},
|
||||||
bank::Bank,
|
bank::Bank,
|
||||||
};
|
};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::{account::ReadableAccount, pubkey::Pubkey};
|
||||||
use solana_stake_program::stake_state::StakeState;
|
use solana_stake_program::stake_state::StakeState;
|
||||||
use std::{collections::HashSet, sync::Arc};
|
use std::{collections::HashSet, sync::Arc};
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ pub fn calculate_non_circulating_supply(bank: &Arc<Bank>) -> NonCirculatingSuppl
|
||||||
// the current AccountsDb implementation, an account may remain in storage as a
|
// the current AccountsDb implementation, an account may remain in storage as a
|
||||||
// zero-lamport Account::Default() after being wiped and reinitialized in later
|
// zero-lamport Account::Default() after being wiped and reinitialized in later
|
||||||
// updates. We include the redundant filter here to avoid returning these accounts.
|
// updates. We include the redundant filter here to avoid returning these accounts.
|
||||||
|account| account.owner == solana_stake_program::id(),
|
|account| account.owner() == &solana_stake_program::id(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
bank.get_program_accounts(&solana_stake_program::id())
|
bank.get_program_accounts(&solana_stake_program::id())
|
||||||
|
|
|
@ -1458,7 +1458,7 @@ impl JsonRpcRequestProcessor {
|
||||||
Error::invalid_params("Invalid param: could not find account".to_string())
|
Error::invalid_params("Invalid param: could not find account".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if account.owner != spl_token_id_v2_0() {
|
if account.owner() != &spl_token_id_v2_0() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token account".to_string(),
|
"Invalid param: not a v2.0 Token account".to_string(),
|
||||||
));
|
));
|
||||||
|
@ -1482,7 +1482,7 @@ impl JsonRpcRequestProcessor {
|
||||||
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
||||||
Error::invalid_params("Invalid param: could not find account".to_string())
|
Error::invalid_params("Invalid param: could not find account".to_string())
|
||||||
})?;
|
})?;
|
||||||
if mint_account.owner != spl_token_id_v2_0() {
|
if mint_account.owner() != &spl_token_id_v2_0() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token mint".to_string(),
|
"Invalid param: not a v2.0 Token mint".to_string(),
|
||||||
));
|
));
|
||||||
|
@ -1660,7 +1660,7 @@ impl JsonRpcRequestProcessor {
|
||||||
// zero-lamport AccountSharedData::Default() after being wiped and reinitialized in later
|
// zero-lamport AccountSharedData::Default() after being wiped and reinitialized in later
|
||||||
// updates. We include the redundant filters here to avoid returning these
|
// updates. We include the redundant filters here to avoid returning these
|
||||||
// accounts.
|
// accounts.
|
||||||
account.owner == *program_id && filter_closure(account)
|
account.owner() == program_id && filter_closure(account)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
bank.get_filtered_program_accounts(program_id, filter_closure)
|
bank.get_filtered_program_accounts(program_id, filter_closure)
|
||||||
|
@ -1696,7 +1696,7 @@ impl JsonRpcRequestProcessor {
|
||||||
.contains(&AccountIndex::SplTokenOwner)
|
.contains(&AccountIndex::SplTokenOwner)
|
||||||
{
|
{
|
||||||
bank.get_filtered_indexed_accounts(&IndexKey::SplTokenOwner(*owner_key), |account| {
|
bank.get_filtered_indexed_accounts(&IndexKey::SplTokenOwner(*owner_key), |account| {
|
||||||
account.owner == spl_token_id_v2_0()
|
account.owner() == &spl_token_id_v2_0()
|
||||||
&& filters.iter().all(|filter_type| match filter_type {
|
&& filters.iter().all(|filter_type| match filter_type {
|
||||||
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
||||||
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
||||||
|
@ -1735,7 +1735,7 @@ impl JsonRpcRequestProcessor {
|
||||||
.contains(&AccountIndex::SplTokenMint)
|
.contains(&AccountIndex::SplTokenMint)
|
||||||
{
|
{
|
||||||
bank.get_filtered_indexed_accounts(&IndexKey::SplTokenMint(*mint_key), |account| {
|
bank.get_filtered_indexed_accounts(&IndexKey::SplTokenMint(*mint_key), |account| {
|
||||||
account.owner == spl_token_id_v2_0()
|
account.owner() == &spl_token_id_v2_0()
|
||||||
&& filters.iter().all(|filter_type| match filter_type {
|
&& filters.iter().all(|filter_type| match filter_type {
|
||||||
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
||||||
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
||||||
|
@ -1838,7 +1838,7 @@ fn get_encoded_account(
|
||||||
) -> Result<Option<UiAccount>> {
|
) -> Result<Option<UiAccount>> {
|
||||||
let mut response = None;
|
let mut response = None;
|
||||||
if let Some(account) = bank.get_account(pubkey) {
|
if let Some(account) = bank.get_account(pubkey) {
|
||||||
if account.owner == spl_token_id_v2_0() && encoding == UiAccountEncoding::JsonParsed {
|
if account.owner() == &spl_token_id_v2_0() && encoding == UiAccountEncoding::JsonParsed {
|
||||||
response = Some(get_parsed_token_account(bank.clone(), pubkey, account));
|
response = Some(get_parsed_token_account(bank.clone(), pubkey, account));
|
||||||
} else if (encoding == UiAccountEncoding::Binary || encoding == UiAccountEncoding::Base58)
|
} else if (encoding == UiAccountEncoding::Binary || encoding == UiAccountEncoding::Base58)
|
||||||
&& account.data().len() > 128
|
&& account.data().len() > 128
|
||||||
|
@ -2008,7 +2008,7 @@ fn get_mint_owner_and_decimals(bank: &Arc<Bank>, mint: &Pubkey) -> Result<(Pubke
|
||||||
Error::invalid_params("Invalid param: could not find mint".to_string())
|
Error::invalid_params("Invalid param: could not find mint".to_string())
|
||||||
})?;
|
})?;
|
||||||
let decimals = get_mint_decimals(&mint_account.data())?;
|
let decimals = get_mint_decimals(&mint_account.data())?;
|
||||||
Ok((mint_account.owner, decimals))
|
Ok((*mint_account.owner(), decimals))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ fn filter_account_result(
|
||||||
// and should notify that the account state has been reverted.
|
// and should notify that the account state has been reverted.
|
||||||
let results: Box<dyn Iterator<Item = UiAccount>> = if last_modified_slot != last_notified_slot {
|
let results: Box<dyn Iterator<Item = UiAccount>> = if last_modified_slot != last_notified_slot {
|
||||||
let encoding = encoding.unwrap_or(UiAccountEncoding::Binary);
|
let encoding = encoding.unwrap_or(UiAccountEncoding::Binary);
|
||||||
if account.owner == spl_token_id_v2_0() && encoding == UiAccountEncoding::JsonParsed {
|
if account.owner() == &spl_token_id_v2_0() && encoding == UiAccountEncoding::JsonParsed {
|
||||||
Box::new(iter::once(get_parsed_token_account(bank, pubkey, account)))
|
Box::new(iter::once(get_parsed_token_account(bank, pubkey, account)))
|
||||||
} else {
|
} else {
|
||||||
Box::new(iter::once(UiAccount::encode(
|
Box::new(iter::once(UiAccount::encode(
|
||||||
|
|
|
@ -2102,7 +2102,7 @@ fn main() {
|
||||||
let data_len = account.data().len();
|
let data_len = account.data().len();
|
||||||
println!("{}:", pubkey);
|
println!("{}:", pubkey);
|
||||||
println!(" - balance: {} SOL", lamports_to_sol(account.lamports));
|
println!(" - balance: {} SOL", lamports_to_sol(account.lamports));
|
||||||
println!(" - owner: '{}'", account.owner);
|
println!(" - owner: '{}'", account.owner());
|
||||||
println!(" - executable: {}", account.executable);
|
println!(" - executable: {}", account.executable);
|
||||||
println!(" - slot: {}", slot);
|
println!(" - slot: {}", slot);
|
||||||
println!(" - rent_epoch: {}", account.rent_epoch);
|
println!(" - rent_epoch: {}", account.rent_epoch);
|
||||||
|
@ -2449,7 +2449,7 @@ fn main() {
|
||||||
rewarded_accounts.sort_unstable_by_key(
|
rewarded_accounts.sort_unstable_by_key(
|
||||||
|(pubkey, account, base_lamports)| {
|
|(pubkey, account, base_lamports)| {
|
||||||
(
|
(
|
||||||
account.owner,
|
account.owner(),
|
||||||
*base_lamports,
|
*base_lamports,
|
||||||
account.lamports - base_lamports,
|
account.lamports - base_lamports,
|
||||||
*pubkey,
|
*pubkey,
|
||||||
|
@ -2469,7 +2469,7 @@ fn main() {
|
||||||
.map(|pubkey| (**pubkey, warped_bank.get_account(pubkey).unwrap()))
|
.map(|pubkey| (**pubkey, warped_bank.get_account(pubkey).unwrap()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
unchanged_accounts.sort_unstable_by_key(|(pubkey, account)| {
|
unchanged_accounts.sort_unstable_by_key(|(pubkey, account)| {
|
||||||
(account.owner, account.lamports, *pubkey)
|
(*account.owner(), account.lamports, *pubkey)
|
||||||
});
|
});
|
||||||
let unchanged_accounts = unchanged_accounts.into_iter();
|
let unchanged_accounts = unchanged_accounts.into_iter();
|
||||||
|
|
||||||
|
@ -2491,7 +2491,7 @@ fn main() {
|
||||||
println!(
|
println!(
|
||||||
"{:<45}({}): {} => {} (+{} {:>4.9}%) {:?}",
|
"{:<45}({}): {} => {} (+{} {:>4.9}%) {:?}",
|
||||||
format!("{}", pubkey), // format! is needed to pad/justify correctly.
|
format!("{}", pubkey), // format! is needed to pad/justify correctly.
|
||||||
base_account.owner,
|
base_account.owner(),
|
||||||
Sol(base_account.lamports),
|
Sol(base_account.lamports),
|
||||||
Sol(warped_account.lamports),
|
Sol(warped_account.lamports),
|
||||||
Sol(delta),
|
Sol(delta),
|
||||||
|
@ -2554,7 +2554,7 @@ fn main() {
|
||||||
cluster_type: format!("{:?}", base_bank.cluster_type()),
|
cluster_type: format!("{:?}", base_bank.cluster_type()),
|
||||||
rewarded_epoch: base_bank.epoch(),
|
rewarded_epoch: base_bank.epoch(),
|
||||||
account: format!("{}", pubkey),
|
account: format!("{}", pubkey),
|
||||||
owner: format!("{}", base_account.owner),
|
owner: format!("{}", base_account.owner()),
|
||||||
old_balance: base_account.lamports,
|
old_balance: base_account.lamports,
|
||||||
new_balance: warped_account.lamports,
|
new_balance: warped_account.lamports,
|
||||||
data_size: base_account.data().len(),
|
data_size: base_account.data().len(),
|
||||||
|
|
|
@ -349,13 +349,13 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs {
|
||||||
let mut data = account_info.try_borrow_mut_data()?;
|
let mut data = account_info.try_borrow_mut_data()?;
|
||||||
let account_borrow = account.borrow();
|
let account_borrow = account.borrow();
|
||||||
let new_data = account_borrow.data();
|
let new_data = account_borrow.data();
|
||||||
if *account_info.owner != account.borrow().owner {
|
if account_info.owner != account.borrow().owner() {
|
||||||
// TODO Figure out a better way to allow the System Program to set the account owner
|
// TODO Figure out a better way to allow the System Program to set the account owner
|
||||||
#[allow(clippy::transmute_ptr_to_ptr)]
|
#[allow(clippy::transmute_ptr_to_ptr)]
|
||||||
#[allow(mutable_transmutes)]
|
#[allow(mutable_transmutes)]
|
||||||
let account_info_mut =
|
let account_info_mut =
|
||||||
unsafe { transmute::<&Pubkey, &mut Pubkey>(account_info.owner) };
|
unsafe { transmute::<&Pubkey, &mut Pubkey>(account_info.owner) };
|
||||||
*account_info_mut = account.borrow().owner;
|
*account_info_mut = *account.borrow().owner();
|
||||||
}
|
}
|
||||||
if data.len() != new_data.len() {
|
if data.len() != new_data.len() {
|
||||||
// TODO: Figure out how to allow the System Program to resize the account data
|
// TODO: Figure out how to allow the System Program to resize the account data
|
||||||
|
|
|
@ -1826,7 +1826,7 @@ fn get_upgradeable_executable(
|
||||||
program_account: &Rc<RefCell<AccountSharedData>>,
|
program_account: &Rc<RefCell<AccountSharedData>>,
|
||||||
invoke_context: &Ref<&mut dyn InvokeContext>,
|
invoke_context: &Ref<&mut dyn InvokeContext>,
|
||||||
) -> Result<Option<(Pubkey, Rc<RefCell<AccountSharedData>>)>, EbpfError<BpfError>> {
|
) -> Result<Option<(Pubkey, Rc<RefCell<AccountSharedData>>)>, EbpfError<BpfError>> {
|
||||||
if program_account.borrow().owner == bpf_loader_upgradeable::id() {
|
if program_account.borrow().owner() == &bpf_loader_upgradeable::id() {
|
||||||
match program_account.borrow().state() {
|
match program_account.borrow().state() {
|
||||||
Ok(UpgradeableLoaderState::Program {
|
Ok(UpgradeableLoaderState::Program {
|
||||||
programdata_address,
|
programdata_address,
|
||||||
|
@ -1992,7 +1992,7 @@ fn call<'a>(
|
||||||
if let Some(account_ref) = account_ref {
|
if let Some(account_ref) = account_ref {
|
||||||
if message.is_writable(i, demote_sysvar_write_locks) && !account.executable {
|
if message.is_writable(i, demote_sysvar_write_locks) && !account.executable {
|
||||||
*account_ref.lamports = account.lamports;
|
*account_ref.lamports = account.lamports;
|
||||||
*account_ref.owner = account.owner;
|
*account_ref.owner = *account.owner();
|
||||||
if account_ref.data.len() != account.data().len() {
|
if account_ref.data.len() != account.data().len() {
|
||||||
if !account_ref.data.is_empty() {
|
if !account_ref.data.is_empty() {
|
||||||
// Only support for `CreateAccount` at this time.
|
// Only support for `CreateAccount` at this time.
|
||||||
|
|
|
@ -572,7 +572,7 @@ mod tests {
|
||||||
&bob_pubkey,
|
&bob_pubkey,
|
||||||
&budget_pubkey,
|
&budget_pubkey,
|
||||||
&game_pubkey,
|
&game_pubkey,
|
||||||
&game_account.owner,
|
game_account.owner(),
|
||||||
game_hash,
|
game_hash,
|
||||||
41,
|
41,
|
||||||
);
|
);
|
||||||
|
|
|
@ -358,7 +358,7 @@ impl Accounts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add loader to chain
|
// Add loader to chain
|
||||||
let program_owner = program.owner;
|
let program_owner = *program.owner();
|
||||||
|
|
||||||
if bpf_loader_upgradeable::check_id(&program_owner) {
|
if bpf_loader_upgradeable::check_id(&program_owner) {
|
||||||
// The upgradeable loader requires the derived ProgramData account
|
// The upgradeable loader requires the derived ProgramData account
|
||||||
|
|
|
@ -111,7 +111,7 @@ fn assign(
|
||||||
invoke_context: &dyn InvokeContext,
|
invoke_context: &dyn InvokeContext,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
// no work to do, just return
|
// no work to do, just return
|
||||||
if account.owner == *owner {
|
if account.owner() == owner {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ pub enum SystemAccountKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_system_account_kind(account: &AccountSharedData) -> Option<SystemAccountKind> {
|
pub fn get_system_account_kind(account: &AccountSharedData) -> Option<SystemAccountKind> {
|
||||||
if system_program::check_id(&account.owner) {
|
if system_program::check_id(account.owner()) {
|
||||||
if account.data().is_empty() {
|
if account.data().is_empty() {
|
||||||
Some(SystemAccountKind::System)
|
Some(SystemAccountKind::System)
|
||||||
} else if account.data().len() == nonce::State::size() {
|
} else if account.data().len() == nonce::State::size() {
|
||||||
|
|
Loading…
Reference in New Issue