Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Jan 29, 2024
1 parent 17e754b commit 04a5ed6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
16 changes: 11 additions & 5 deletions applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tari_common::{
exit_codes::{ExitCode, ExitError},
};
use tari_comms::{
multiaddr::Multiaddr,
multiaddr::{Error as MultiaddrError, Multiaddr},
peer_manager::Peer,
protocol::rpc::RpcServer,
tor::TorIdentity,
Expand Down Expand Up @@ -177,11 +177,17 @@ where B: BlockchainBackend + 'static
let path = base_node_config.tor_identity_file.clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let _result = identity_management::save_as_json(&path, &identity);
let address_string = format!("/onion3/{}:{}", identity.service_id, identity.onion_port);
if let Err(e) = identity_management::save_as_json(&path, &identity) {
error!(target: LOG_TARGET, "Failed to save tor identity{:?}", e);
}
trace!(target: LOG_TARGET, "resave the tor identity {:?}", identity);
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
.expect("Should be able to create address");
let result: Result<Multiaddr, MultiaddrError> = address_string.parse();
if result.is_err() {
error!(target: LOG_TARGET, "Failed to parse tor identity as multiaddr{:?}", result);
return;
}
let address = result.unwrap();
if !node_id.public_addresses().contains(&address) {
node_id.add_public_address(address);
}
Expand Down
18 changes: 12 additions & 6 deletions base_layer/contacts/src/chat_client/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

use std::{str::FromStr, sync::Arc, time::Duration};

use log::trace;
use log::{error, trace};
use minotari_app_utilities::{identity_management, identity_management::load_from_json};
// Re-exports
pub use tari_comms::{
multiaddr::Multiaddr,
multiaddr::{Error as MultiaddrError, Multiaddr},
peer_manager::{NodeIdentity, PeerFeatures},
};
use tari_comms::{peer_manager::Peer, tor::TorIdentity, CommsNode, UnspawnedCommsNode};
Expand Down Expand Up @@ -113,10 +113,16 @@ pub async fn start(
let path = config.chat_client.tor_identity_file.clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let _result = identity_management::save_as_json(&path, &identity);
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
.expect("Should be able to create address");
let address_string = format!("/onion3/{}:{}", identity.service_id, identity.onion_port);
if let Err(e) = identity_management::save_as_json(&path, &identity) {
error!(target: LOG_TARGET, "Failed to save tor identity{:?}", e);
}
let result: Result<Multiaddr, MultiaddrError> = address_string.parse();
if result.is_err() {
error!(target: LOG_TARGET, "Failed to parse tor identity as multiaddr{:?}", result);
return;
}
let address = result.unwrap();
trace!(target: LOG_TARGET, "resave the chat tor identity {:?}", identity);
if !node_id.public_addresses().contains(&address) {
node_id.add_public_address(address);
Expand Down
16 changes: 11 additions & 5 deletions base_layer/wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tari_common_types::{
types::{ComAndPubSignature, Commitment, PrivateKey, PublicKey, SignatureWithDomain},
};
use tari_comms::{
multiaddr::Multiaddr,
multiaddr::{Error as MultiaddrError, Multiaddr},
net_address::{MultiaddressesWithStats, PeerAddressSource},
peer_manager::{NodeId, Peer, PeerFeatures, PeerFlags},
tor::TorIdentity,
Expand Down Expand Up @@ -261,10 +261,16 @@ where
let wallet_db = wallet_database.clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
.expect("Should be able to create address");
let _result = wallet_db.set_tor_identity(identity);
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);
}
let result: Result<Multiaddr, MultiaddrError> = address_string.parse();
if result.is_err() {
error!(target: LOG_TARGET, "Failed to parse tor identity as multiaddr{:?}", result);
return;
}
let address = result.unwrap();
if !node_id.public_addresses().contains(&address) {
node_id.add_public_address(address.clone());
}
Expand Down
16 changes: 0 additions & 16 deletions base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5471,12 +5471,6 @@ pub unsafe extern "C" fn wallet_create(

match w {
Ok(w) => {
// lets ensure the wallet tor_id is saved, this could have been changed during wallet startup
// if let Some(hs) = w.comms.hidden_service() {
// if let Err(e) = w.db.set_tor_identity(hs.tor_identity().clone()) {
// warn!(target: LOG_TARGET, "Could not save tor identity to db: {:?}", e);
// }
// }
let wallet_address = TariAddress::new(w.comms.node_identity().public_key().clone(), w.network.as_network());

// Start Callback Handler
Expand Down Expand Up @@ -5512,16 +5506,6 @@ pub unsafe extern "C" fn wallet_create(

runtime.spawn(callback_handler.start());

// let mut ts = w.transaction_service.clone();
// runtime.spawn(async move {
// if let Err(e) = ts.restart_transaction_protocols().await {
// warn!(
// target: LOG_TARGET,
// "Could not restart transaction negotiation protocols: {:?}", e
// );
// }
// });

let tari_wallet = TariWallet {
wallet: w,
runtime,
Expand Down

0 comments on commit 04a5ed6

Please sign in to comment.