Skip to content

Commit

Permalink
Persist exchange account name in deposit address
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jan 6, 2024
1 parent 944b273 commit a773f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,16 +749,16 @@ impl Db {
Ok(())
}

pub fn get_default_accounts_from_all_configured_exchanges(
pub fn get_default_accounts_from_configured_exchanges(
&self,
) -> Vec<(Exchange, ExchangeCredentials)> {
) -> Vec<(Exchange, ExchangeCredentials, String)> {
self.credentials_db
.get_all()
.into_iter()
.filter_map(|key| {
if let Ok(exchange) = key.parse() {
self.get_exchange_credentials(exchange, "")
.map(|exchange_credentials| (exchange, exchange_credentials))
.map(|exchange_credentials| (exchange, exchange_credentials, "".into()))
} else {
None
}
Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ async fn get_block_date_and_price(
fn add_exchange_deposit_address_to_db(
db: &mut Db,
exchange: Exchange,
exchange_account: &str,
token: MaybeToken,
deposit_address: Pubkey,
rpc_client: &RpcClient,
Expand All @@ -137,7 +138,7 @@ fn add_exchange_deposit_address_to_db(
db.add_account(TrackedAccount {
address: deposit_address,
token,
description: format!("{exchange:?}"),
description: format!("{exchange:?} {exchange_account}"),
last_update_epoch: epoch,
last_update_balance: 0,
lots: vec![],
Expand Down Expand Up @@ -5579,10 +5580,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
("sync", Some(arg_matches)) => {
let max_epochs_to_process = value_t!(arg_matches, "max_epochs_to_process", u64).ok();
process_sync_swaps(&mut db, &rpc_client, &notifier).await?;
for (exchange, exchange_credentials) in
db.get_default_accounts_from_all_configured_exchanges()
for (exchange, exchange_credentials, exchange_account) in
db.get_default_accounts_from_configured_exchanges()
{
println!("Synchronizing {exchange:?}...");
println!("Synchronizing {exchange:?} {exchange_account}...");
let exchange_client = exchange_client_new(exchange, exchange_credentials)?;
process_sync_exchange(
&mut db,
Expand Down Expand Up @@ -6415,6 +6416,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
add_exchange_deposit_address_to_db(
&mut db,
exchange,
&exchange_account,
token,
deposit_address,
&rpc_client,
Expand Down Expand Up @@ -6465,6 +6467,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
add_exchange_deposit_address_to_db(
&mut db,
exchange,
&exchange_account,
token,
deposit_address,
&rpc_client,
Expand Down

0 comments on commit a773f1e

Please sign in to comment.