Skip to content

Commit

Permalink
provider: have one source of truth for protocol_version
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Jul 9, 2024
1 parent 84824bc commit 561868d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 2 additions & 4 deletions agent/provider/src/provider_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,8 @@ impl ProviderAgent {
Ok(NodeInfo {
name: globals.node_name,
subnet: globals.subnet,
geo_country_code: None,
is_public: status.public_ip.is_some(),
protocol_version: 3,
..Default::default()
})
}

Expand Down Expand Up @@ -641,9 +640,8 @@ mod tests {
let node_info = NodeInfo {
name: Some("node_name".to_string()),
subnet: Some("subnet".to_string()),
geo_country_code: None,
is_public: true,
protocol_version: 3,
..Default::default()
};
let inf_node_info = InfNodeInfo::default();
let accounts = Vec::new();
Expand Down
17 changes: 13 additions & 4 deletions utils/agreement-utils/src/typed_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ pub struct NodeInfo {
pub protocol_version: u32,
}

impl NodeInfo {
pub fn with_name(name: impl Into<String>) -> Self {
impl Default for NodeInfo {
fn default() -> Self {
NodeInfo {
name: Some(name.into()),
geo_country_code: None,
name: None,
subnet: None,
geo_country_code: None,
is_public: false,
protocol_version: 3,
}
}
}

impl NodeInfo {
pub fn with_name(name: impl Into<String>) -> Self {
NodeInfo {
name: Some(name.into()),
..Default::default()
}
}

pub fn with_subnet(&mut self, subnet: String) -> &mut Self {
self.subnet = Some(subnet);
Expand Down

0 comments on commit 561868d

Please sign in to comment.