Skip to content

Commit

Permalink
feat: wallet add restart validation to start (#6113)
Browse files Browse the repository at this point in the history
Description
---
Adds back the restart tx protocols on wallet start

Motivation and Context
---
The wallet should restart its transactions protocols on start
  • Loading branch information
SWvheerden authored Feb 2, 2024
1 parent 38b9113 commit 5c236ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion base_layer/wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{cmp, marker::PhantomData, sync::Arc};

use blake2::Blake2b;
use digest::consts::U32;
use futures::executor::block_on;
use log::*;
use rand::rngs::OsRng;
use tari_common::configuration::bootstrap::ApplicationType;
Expand Down Expand Up @@ -254,13 +255,17 @@ where

let mut handles = stack.build().await?;

let transaction_service_handle = handles.expect_handle::<TransactionServiceHandle>();
let comms = handles
.take_handle::<UnspawnedCommsNode>()
.expect("P2pInitializer was not added to the stack");
let comms = if config.p2p.transport.transport_type == TransportType::Tor {
let wallet_db = wallet_database.clone();
let node_id = comms.node_identity();
let moved_ts_clone = transaction_service_handle.clone();
let after_comms = move |identity: TorIdentity| {
// we do this so that we dont have to move in a mut ref and making the closure a FnMut.
let mut ts = moved_ts_clone.clone();
let address_string = format!("/onion3/{}:{}", identity.service_id, identity.onion_port);
if let Err(e) = wallet_db.set_tor_identity(identity) {
error!(target: LOG_TARGET, "Failed to set wallet db tor identity{:?}", e);
Expand All @@ -278,6 +283,13 @@ where
// made during comms startup. In the case of a Tor Transport the public address could
// have been generated
let _result = wallet_db.set_node_address(address);
let result = block_on(ts.restart_transaction_protocols());
if result.is_err() {
warn!(
target: LOG_TARGET,
"Could not restart transaction negotiation protocols: {:?}", result
);
}
};
initialization::spawn_comms_using_transport(comms, config.p2p.transport, after_comms).await?
} else {
Expand All @@ -287,7 +299,6 @@ where

let mut output_manager_handle = handles.expect_handle::<OutputManagerHandle>();
let key_manager_handle = handles.expect_handle::<TKeyManagerInterface>();
let transaction_service_handle = handles.expect_handle::<TransactionServiceHandle>();
let contacts_handle = handles.expect_handle::<ContactsServiceHandle>();
let dht = handles.expect_handle::<Dht>();
let store_and_forward_requester = dht.store_and_forward_requester();
Expand Down

0 comments on commit 5c236ce

Please sign in to comment.