Skip to content

Commit

Permalink
fix: ensure peers are added to peer list before recovery starts (#3186)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Aug 17, 2021
2 parents c79e53c + 87fd4cc commit 5f33414
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion applications/tari_app_utilities/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use log::*;
use tari_common::{CommsTransport, GlobalConfig, SocksAuthentication, TorControlAuthentication};
use tari_comms::{
connectivity::ConnectivityError,
peer_manager::NodeId,
peer_manager::{NodeId, PeerManagerError},
protocol::rpc::RpcError,
socks,
tor,
Expand Down Expand Up @@ -146,6 +146,12 @@ impl From<WalletStorageError> for ExitCodes {
}
}

impl From<PeerManagerError> for ExitCodes {
fn from(err: PeerManagerError) -> Self {
ExitCodes::NetworkError(err.to_string())
}
}

impl ExitCodes {
pub fn grpc<M: std::fmt::Display>(err: M) -> Self {
ExitCodes::GrpcError(format!("GRPC connection error: {}", err))
Expand Down
13 changes: 8 additions & 5 deletions applications/tari_console_wallet/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ pub async fn wallet_recovery(wallet: &WalletSqlite, base_node_config: &PeerConfi
let shutdown = Shutdown::new();
let shutdown_signal = shutdown.to_signal();

let peer_public_keys = base_node_config
.get_all_peers()
.iter()
.map(|peer| peer.public_key.clone())
.collect();
let peers = base_node_config.get_all_peers();

let peer_manager = wallet.comms.peer_manager();
let mut peer_public_keys = Vec::with_capacity(peers.len());
for peer in peers {
peer_public_keys.push(peer.public_key.clone());
peer_manager.add_peer(peer).await?;
}

let mut recovery_task = UtxoScannerService::<WalletSqliteDatabase>::builder()
.with_peers(peer_public_keys)
Expand Down

0 comments on commit 5f33414

Please sign in to comment.