Add ability to abort scan (#21314)
This commit is contained in:
committed by
GitHub
parent
e540b1cf3c
commit
0f69a14247
@ -39,7 +39,7 @@ use {
|
||||
solana_perf::packet::PACKET_DATA_SIZE,
|
||||
solana_runtime::{
|
||||
accounts::AccountAddressFilter,
|
||||
accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey},
|
||||
accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey, ScanConfig},
|
||||
bank::{Bank, TransactionSimulationResult},
|
||||
bank_forks::BankForks,
|
||||
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
|
||||
@ -1830,20 +1830,24 @@ impl JsonRpcRequestProcessor {
|
||||
});
|
||||
}
|
||||
Ok(bank
|
||||
.get_filtered_indexed_accounts(&IndexKey::ProgramId(*program_id), |account| {
|
||||
// The program-id account index checks for Account owner on inclusion. However, due
|
||||
// to the current AccountsDb implementation, an account may remain in storage as a
|
||||
// zero-lamport AccountSharedData::Default() after being wiped and reinitialized in later
|
||||
// updates. We include the redundant filters here to avoid returning these
|
||||
// accounts.
|
||||
account.owner() == program_id && filter_closure(account)
|
||||
})
|
||||
.get_filtered_indexed_accounts(
|
||||
&IndexKey::ProgramId(*program_id),
|
||||
|account| {
|
||||
// The program-id account index checks for Account owner on inclusion. However, due
|
||||
// to the current AccountsDb implementation, an account may remain in storage as a
|
||||
// zero-lamport AccountSharedData::Default() after being wiped and reinitialized in later
|
||||
// updates. We include the redundant filters here to avoid returning these
|
||||
// accounts.
|
||||
account.owner() == program_id && filter_closure(account)
|
||||
},
|
||||
ScanConfig::default(),
|
||||
)
|
||||
.map_err(|e| RpcCustomError::ScanError {
|
||||
message: e.to_string(),
|
||||
})?)
|
||||
} else {
|
||||
Ok(bank
|
||||
.get_filtered_program_accounts(program_id, filter_closure)
|
||||
.get_filtered_program_accounts(program_id, filter_closure, ScanConfig::default())
|
||||
.map_err(|e| RpcCustomError::ScanError {
|
||||
message: e.to_string(),
|
||||
})?)
|
||||
@ -1884,13 +1888,21 @@ impl JsonRpcRequestProcessor {
|
||||
});
|
||||
}
|
||||
Ok(bank
|
||||
.get_filtered_indexed_accounts(&IndexKey::SplTokenOwner(*owner_key), |account| {
|
||||
account.owner() == &spl_token_id_v2_0()
|
||||
&& filters.iter().all(|filter_type| match filter_type {
|
||||
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
||||
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
||||
})
|
||||
})
|
||||
.get_filtered_indexed_accounts(
|
||||
&IndexKey::SplTokenOwner(*owner_key),
|
||||
|account| {
|
||||
account.owner() == &spl_token_id_v2_0()
|
||||
&& filters.iter().all(|filter_type| match filter_type {
|
||||
RpcFilterType::DataSize(size) => {
|
||||
account.data().len() as u64 == *size
|
||||
}
|
||||
RpcFilterType::Memcmp(compare) => {
|
||||
compare.bytes_match(account.data())
|
||||
}
|
||||
})
|
||||
},
|
||||
ScanConfig::default(),
|
||||
)
|
||||
.map_err(|e| RpcCustomError::ScanError {
|
||||
message: e.to_string(),
|
||||
})?)
|
||||
@ -1932,13 +1944,21 @@ impl JsonRpcRequestProcessor {
|
||||
});
|
||||
}
|
||||
Ok(bank
|
||||
.get_filtered_indexed_accounts(&IndexKey::SplTokenMint(*mint_key), |account| {
|
||||
account.owner() == &spl_token_id_v2_0()
|
||||
&& filters.iter().all(|filter_type| match filter_type {
|
||||
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
||||
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
||||
})
|
||||
})
|
||||
.get_filtered_indexed_accounts(
|
||||
&IndexKey::SplTokenMint(*mint_key),
|
||||
|account| {
|
||||
account.owner() == &spl_token_id_v2_0()
|
||||
&& filters.iter().all(|filter_type| match filter_type {
|
||||
RpcFilterType::DataSize(size) => {
|
||||
account.data().len() as u64 == *size
|
||||
}
|
||||
RpcFilterType::Memcmp(compare) => {
|
||||
compare.bytes_match(account.data())
|
||||
}
|
||||
})
|
||||
},
|
||||
ScanConfig::default(),
|
||||
)
|
||||
.map_err(|e| RpcCustomError::ScanError {
|
||||
message: e.to_string(),
|
||||
})?)
|
||||
|
Reference in New Issue
Block a user