Skip to content

Commit

Permalink
set default value for local_network_id
Browse files Browse the repository at this point in the history
  • Loading branch information
haxjump committed Nov 4, 2024
1 parent 3f83964 commit e201d0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chaindev"
version = "0.50.2"
version = "0.51.0"
edition = "2021"
authors = ["hui.fan@mail.ru"]
description = "Powerful development and testing utils for blockchain developers."
Expand Down
9 changes: 6 additions & 3 deletions src/common/hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ use std::{
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)]
pub struct HostAddr {
pub local_ip: String,
#[serde(default)]
#[serde(default = "default_local_network_id")]
pub local_network_id: String,
pub ext_ip: Option<String>,
}

fn default_local_network_id() -> String {
"default_mlm_mmm_lqm_qmzl_9527".to_owned()
}

impl HostAddr {
#[inline(always)]
pub fn connection_addr(&self) -> &str {
Expand All @@ -24,8 +28,7 @@ impl HostAddr {
/// Use the local ip to get better performance,
/// if they are locating in the same local network
pub fn connection_addr_x(&self, local_network_id: &str) -> &str {
if !self.local_network_id.is_empty()
&& self.local_network_id == local_network_id
if self.local_network_id == local_network_id
{
&self.local_ip
} else {
Expand Down

0 comments on commit e201d0d

Please sign in to comment.