Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc-client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
solana-account-decoder = { workspace = true }
solana-inline-spl = { workspace = true }
solana-sdk = { workspace = true }
solana-transaction-status = { workspace = true }
solana-version = { workspace = true }
spl-token-2022 = { workspace = true, features = ["no-entrypoint"] }
thiserror = { workspace = true }

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion rpc-client-api/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(deprecated)]
use {
crate::version_req::VersionReq,
solana_inline_spl::{token::GenericTokenAccount, token_2022::Account},
solana_sdk::account::{AccountSharedData, ReadableAccount},
spl_token_2022::{generic_token_account::GenericTokenAccount, state::Account},
std::borrow::Cow,
thiserror::Error,
};
Expand Down Expand Up @@ -79,6 +79,7 @@ impl RpcFilterType {
}
}

#[deprecated = "Use solana_rpc::filter::filter_allows instead"]
pub fn allows(&self, account: &AccountSharedData) -> bool {
Comment thread
kevinheavey marked this conversation as resolved.
Outdated
match self {
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
Expand Down
13 changes: 13 additions & 0 deletions rpc/src/filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use {
solana_inline_spl::{token::GenericTokenAccount, token_2022::Account},
solana_rpc_client_api::filter::RpcFilterType,
solana_sdk::account::{AccountSharedData, ReadableAccount},
};

pub fn filter_allows(filter: &RpcFilterType, account: &AccountSharedData) -> bool {
match filter {
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
RpcFilterType::TokenAccountState => Account::valid_account_data(account.data()),
}
}
1 change: 1 addition & 0 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(clippy::arithmetic_side_effects)]
mod cluster_tpu_info;
pub mod filter;
pub mod max_slots;
pub mod optimistically_confirmed_bank_tracker;
pub mod parsed_token_accounts;
Expand Down
9 changes: 5 additions & 4 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! The `rpc` module implements the Solana RPC interface.
use {
crate::{
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
filter::filter_allows, max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
parsed_token_accounts::*, rpc_cache::LargestAccountsCache, rpc_health::*,
},
base64::{prelude::BASE64_STANDARD, Engine},
Expand Down Expand Up @@ -2039,7 +2040,7 @@ impl JsonRpcRequestProcessor {
let filter_closure = |account: &AccountSharedData| {
filters
.iter()
.all(|filter_type| filter_type.allows(account))
.all(|filter_type| filter_allows(filter_type, account))
};
if self
.config
Expand Down Expand Up @@ -2116,7 +2117,7 @@ impl JsonRpcRequestProcessor {
account.owner() == program_id
&& filters
.iter()
.all(|filter_type| filter_type.allows(account))
.all(|filter_type| filter_allows(filter_type, account))
},
&ScanConfig::default(),
bank.byte_limit_for_scans(),
Expand Down Expand Up @@ -2166,7 +2167,7 @@ impl JsonRpcRequestProcessor {
account.owner() == program_id
&& filters
.iter()
.all(|filter_type| filter_type.allows(account))
.all(|filter_type| filter_allows(filter_type, account))
},
&ScanConfig::default(),
bank.byte_limit_for_scans(),
Expand Down
3 changes: 2 additions & 1 deletion rpc/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use {
crate::{
filter::filter_allows,
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
parsed_token_accounts::{get_parsed_token_account, get_parsed_token_accounts},
rpc_pubsub_service::PubSubConfig,
Expand Down Expand Up @@ -416,7 +417,7 @@ fn filter_program_results(
let keyed_accounts = accounts.into_iter().filter(move |(_, account)| {
filters
.iter()
.all(|filter_type| filter_type.allows(account))
.all(|filter_type| filter_allows(filter_type, account))
});
let accounts = if is_known_spl_token_id(&params.pubkey)
&& params.encoding == UiAccountEncoding::JsonParsed
Expand Down