From be6d9b1f16db4096761693b0f99b7064a764fdb0 Mon Sep 17 00:00:00 2001 From: Arrowana Date: Mon, 19 Feb 2024 12:09:53 +1100 Subject: [PATCH] Accounts from path --- examples/rust/src/bin/client.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/rust/src/bin/client.rs b/examples/rust/src/bin/client.rs index 9da6c7d9..b27bde14 100644 --- a/examples/rust/src/bin/client.rs +++ b/examples/rust/src/bin/client.rs @@ -8,6 +8,7 @@ use { std::{ collections::HashMap, env, fmt, + fs::File, sync::{Arc, Mutex}, time::Duration, }, @@ -106,6 +107,10 @@ struct ActionSubscribe { #[clap(long)] accounts_account: Vec, + /// Path to a json array of account addresses + #[clap(long)] + accounts_accounts_path: Option, + /// Filter by Owner Pubkey #[clap(long)] accounts_owner: Vec, @@ -207,6 +212,13 @@ impl Action { Self::Subscribe(args) => { let mut accounts: AccountFilterMap = HashMap::new(); if args.accounts { + let mut accounts_account = args.accounts_account.clone(); + if let Some(path) = args.accounts_accounts_path.as_ref() { + let file = File::open(path)?; + let accounts: Vec = serde_json::from_reader(file)?; + accounts_account.extend(accounts); + } + let mut filters = vec![]; for filter in args.accounts_memcmp.iter() { match filter.split_once(',') { @@ -241,7 +253,7 @@ impl Action { accounts.insert( "client".to_owned(), SubscribeRequestFilterAccounts { - account: args.accounts_account.clone(), + account: accounts_account, owner: args.accounts_owner.clone(), filters, },