Skip to content

Commit

Permalink
feat: validator node shows its public key on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Jan 24, 2022
1 parent 61e985c commit b16a001
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions applications/tari_validator_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async fn run_node(config: GlobalConfig, create_id: bool) -> Result<(), ExitCodes
)?;
let db_factory = SqliteDbFactory::new(&config);
let mempool_service = MempoolServiceHandle::default();

info!(
target: LOG_TARGET,
"Node starting with pub key: {}, node_id: {}",
Expand Down Expand Up @@ -133,6 +134,8 @@ async fn run_node(config: GlobalConfig, create_id: bool) -> Result<(), ExitCodes
let grpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 18144);

task::spawn(run_grpc(grpc_server, grpc_addr, shutdown.to_signal()));
println!("🚀 Validator node started!");
println!("{}", node_identity);
run_dan_node(
shutdown.to_signal(),
config,
Expand Down
15 changes: 12 additions & 3 deletions comms/src/peer_manager/node_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ impl NodeIdentity {
acquire_read_lock!(self.public_address).clone()
}

/// Modify the public address. The account signature will be invalid
/// Modify the public address.
pub fn set_public_address(&self, address: Multiaddr) {
*acquire_write_lock!(self.public_address) = address;
self.sign()
let mut must_sign = false;
{
let mut lock = acquire_write_lock!(self.public_address);
if *lock != address {
*lock = address;
must_sign = true;
}
}
if must_sign {
self.sign()
}
}

/// This returns a random NodeIdentity for testing purposes. This function can panic. If public_address
Expand Down

0 comments on commit b16a001

Please sign in to comment.