diff --git a/accounts_on_demand/src/accounts_on_demand.rs b/accounts_on_demand/src/accounts_on_demand.rs index d1b0969..50ffd3b 100644 --- a/accounts_on_demand/src/accounts_on_demand.rs +++ b/accounts_on_demand/src/accounts_on_demand.rs @@ -1,5 +1,5 @@ use std::{ - collections::{BTreeMap, HashMap}, + collections::{BTreeMap, HashMap, HashSet}, sync::Arc, time::Duration, }; @@ -111,18 +111,20 @@ impl AccountStorageInterface for AccountsOnDemand { // create a notify for accounts under loading lk.insert(account_pk, Arc::new(Notify::new())); log::debug!("subscribing to accounts update : {}", account_pk); + let mut hash_set = HashSet::new(); + hash_set.insert(account_pk); self.accounts_source - .subscribe_account(account_pk) + .subscribe_accounts(hash_set) .await .map_err(|_| AccountLoadingError::ErrorSubscribingAccount)?; drop(lk); // save snapshot - let account_filter = AccountFilter { + let account_filter = vec![AccountFilter { accounts: vec![account_pk], program_id: None, filters: None, - }; + }]; self.accounts_source .save_snapshot(self.accounts_storage.clone(), account_filter) .await @@ -204,7 +206,7 @@ impl AccountStorageInterface for AccountsOnDemand { .await; self.accounts_source - .save_snapshot(self.accounts_storage.clone(), account_filter) + .save_snapshot(self.accounts_storage.clone(), vec![account_filter]) .await .map_err(|_| AccountLoadingError::ErrorCreatingSnapshot)?; // update loading lock diff --git a/common/src/accounts_source_interface.rs b/common/src/accounts_source_interface.rs index 56774ca..d55adb7 100644 --- a/common/src/accounts_source_interface.rs +++ b/common/src/accounts_source_interface.rs @@ -1,15 +1,15 @@ use crate::{ - account_filter::{AccountFilter, AccountFilterType}, + account_filter::{AccountFilterType, AccountFilters}, account_store_interface::AccountStorageInterface, }; use async_trait::async_trait; use solana_sdk::pubkey::Pubkey; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; // Source to create snapshot and subscribe to new accounts #[async_trait] pub trait AccountsSourceInterface: Send + Sync { - async fn subscribe_account(&self, account: Pubkey) -> anyhow::Result<()>; + async fn subscribe_accounts(&self, account: HashSet) -> anyhow::Result<()>; async fn subscribe_program_accounts( &self, @@ -20,6 +20,6 @@ pub trait AccountsSourceInterface: Send + Sync { async fn save_snapshot( &self, storage: Arc, - account_filter: AccountFilter, + account_filters: AccountFilters, ) -> anyhow::Result<()>; }