Don't reopen monero wallet on each subscription monitor run

This commit is contained in:
silverpill 2023-03-28 00:10:49 +00:00
parent 8cfb2318a2
commit 378d94e7b8
2 changed files with 15 additions and 5 deletions

View file

@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fixed error in emoji update SQL query. - Fixed error in emoji update SQL query.
- Restart stalled background jobs. - Restart stalled background jobs.
- Order attachments by creation date. - Order attachments by creation date.
- Don't reopen monero wallet on each subscription monitor run.
## [1.18.0] - 2023-03-21 ## [1.18.0] - 2023-03-21

View file

@ -56,11 +56,20 @@ pub async fn open_monero_wallet(
let wallet_client = RpcClientBuilder::new() let wallet_client = RpcClientBuilder::new()
.build(config.wallet_url.clone())? .build(config.wallet_url.clone())?
.wallet(); .wallet();
if let Some(ref wallet_name) = config.wallet_name { if let Err(error) = wallet_client.refresh(None).await {
wallet_client.open_wallet( if error.to_string() == "Server error: No wallet file" {
wallet_name.clone(), // Try to open wallet
config.wallet_password.clone(), if let Some(ref wallet_name) = config.wallet_name {
).await?; wallet_client.open_wallet(
wallet_name.clone(),
config.wallet_password.clone(),
).await?;
} else {
return Err(MoneroError::WalletRpcError("wallet file is required"));
};
} else {
return Err(error.into());
};
}; };
Ok(wallet_client) Ok(wallet_client)
} }