Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: automatically set base node fetures on startup, sign only if necessary #5108

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions applications/tari_app_utilities/src/identity_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ pub fn setup_node_identity<P: AsRef<Path>>(
peer_features: PeerFeatures,
) -> Result<Arc<NodeIdentity>, ExitError> {
match load_node_identity(&identity_file) {
Ok(id) => match public_address {
Some(public_address) => {
id.set_public_address(public_address.clone());
Ok(Arc::new(id))
},
None => Ok(Arc::new(id)),
Ok(mut id) => {
id.set_peer_features(peer_features);
match public_address {
Some(public_address) => {
id.set_public_address(public_address.clone());
Ok(Arc::new(id))
},
None => Ok(Arc::new(id)),
}
},
Err(IdentityError::InvalidPermissions) => Err(ExitError::new(
ExitCode::ConfigError,
Expand Down
9 changes: 9 additions & 0 deletions comms/core/src/peer_manager/node_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ impl NodeIdentity {
}
}

/// Modify the peer features
pub fn set_peer_features(&mut self, features: PeerFeatures) {
let must_sign = features != self.features;
self.features = features;
if must_sign {
self.sign()
}
}

/// This returns a random NodeIdentity for testing purposes. This function can panic. If public_address
/// is None, 127.0.0.1:9000 will be used (i.e. the caller doesn't care what the control_service_address is).
#[cfg(test)]
Expand Down