Skip to content

Commit

Permalink
Accounts from path
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana committed Feb 19, 2024
1 parent ce9f054 commit be6d9b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion examples/rust/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use {
std::{
collections::HashMap,
env, fmt,
fs::File,
sync::{Arc, Mutex},
time::Duration,
},
Expand Down Expand Up @@ -106,6 +107,10 @@ struct ActionSubscribe {
#[clap(long)]
accounts_account: Vec<String>,

/// Path to a json array of account addresses
#[clap(long)]
accounts_accounts_path: Option<String>,

/// Filter by Owner Pubkey
#[clap(long)]
accounts_owner: Vec<String>,
Expand Down Expand Up @@ -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<String> = serde_json::from_reader(file)?;
accounts_account.extend(accounts);
}

let mut filters = vec![];
for filter in args.accounts_memcmp.iter() {
match filter.split_once(',') {
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit be6d9b1

Please sign in to comment.