Last active
July 18, 2024 00:48
-
-
Save RohanKapurDEV/7f1be8b8ad9f4918433f5a686a932264 to your computer and use it in GitHub Desktop.
gpa call - occasional timeouts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "batch_process" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
base58 = "0.2.0" | |
base64 = "0.22.1" | |
hex = "0.4.3" | |
serde = { version = "1.0.204", features = ["derive"] } | |
serde_json = "1.0.120" | |
tokio = { version = "1.38.0", features = ["full"] } | |
solana-client = "1.14.16" | |
solana-sdk = "1.14.16" | |
solana-transaction-status = "1.14.16" | |
solana-account-decoder = "1.14.16" | |
# spl-associated-token-account = "1.1.2" | |
solana-address-lookup-table-program = "1.14.16" | |
dotenv = "0.15.0" | |
squads-multisig = "0.0.23" | |
anchor-client = "0.27.0" | |
redis = { version = "0.23.0", features = ["tokio-rustls-comp"] } | |
reqwest = { version = "0.11.6", features = ["json"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const BATCH_ACCOUNT_DISCRIMINATOR: &str = "9cc2462c1658892c"; | |
pub const SQUADS_V4_PROGRAM_ID: &str = "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf"; | |
/// Solana getProgramAccounts RPC call for Batch accounts on squads v4 | |
pub async fn fetch_all_batch_accounts() -> Vec<Pubkey> { | |
let rpc_url = std::env::var("RPC_URL").unwrap(); | |
let rpc_client = RpcClient::new_with_commitment(rpc_url, CommitmentConfig::confirmed()); | |
let program_id = Pubkey::from_str(SQUADS_V4_PROGRAM_ID).unwrap(); | |
let batch_account_discrim = Vec::from_hex(&BATCH_ACCOUNT_DISCRIMINATOR).unwrap(); | |
let config = RpcProgramAccountsConfig { | |
#[allow(deprecated)] | |
filters: Some(vec![RpcFilterType::Memcmp(Memcmp { | |
offset: 0, | |
bytes: MemcmpEncodedBytes::Bytes(batch_account_discrim), | |
encoding: None, | |
})]), | |
with_context: None, | |
account_config: RpcAccountInfoConfig { | |
encoding: Some(UiAccountEncoding::Base64), | |
commitment: Some(CommitmentConfig::confirmed()), | |
..Default::default() | |
}, | |
}; | |
let start = SystemTime::now(); | |
let since_the_epoch = start | |
.duration_since(UNIX_EPOCH) | |
.expect("Time went backwards"); | |
println!("{:?}", since_the_epoch); | |
let accounts = rpc_client | |
.get_program_accounts_with_config(&program_id, config) | |
.await | |
.unwrap(); | |
println!("Batch accounts len: {:?}", accounts.len()); | |
let pubkeys: Vec<Pubkey> = accounts.iter().map(|account| account.0).collect(); | |
pubkeys | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment