Skip to content

Commit

Permalink
Merge branch 'origin/bengt/init_network-fix' (#1662)
Browse files Browse the repository at this point in the history
* origin/bengt/init_network-fix:
  clippy
  fmt and clippy
  hopefully fixes init_network
  • Loading branch information
Fraccaman committed Jul 6, 2023
2 parents c2779df + f55eb66 commit 7936f71
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,33 +786,41 @@ pub fn init_network(
config.ledger.cometbft.p2p.addr_book_strict = !localhost;
// Clear the net address from the config and use it to set ports
let net_address = validator_config.net_address.take().unwrap();
let ip = SocketAddr::from_str(&net_address).unwrap().ip();
let _ip = SocketAddr::from_str(&net_address).unwrap().ip();
let first_port = SocketAddr::from_str(&net_address).unwrap().port();
if !localhost {
if localhost {
config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(
&format!("127.0.0.1:{}", first_port),
)
.unwrap();
} else {
config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(
&format!("0.0.0.0:{}", first_port),
)
.unwrap();
}
config.ledger.cometbft.p2p.laddr =
TendermintAddress::from_str(&format!("{}:{}", ip, first_port))
.unwrap();
if !localhost {
if localhost {
config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(
&format!("127.0.0.1:{}", first_port + 1),
)
.unwrap();
} else {
config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(
&format!("0.0.0.0:{}", first_port + 1),
)
.unwrap();
}
config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(
&format!("{}:{}", ip, first_port + 1),
)
.unwrap();

config.ledger.cometbft.proxy_app = TendermintAddress::from_str(
&format!("{}:{}", ip, first_port + 2),
)
.unwrap();

if localhost {
config.ledger.cometbft.proxy_app = TendermintAddress::from_str(
&format!("127.0.0.1:{}", first_port + 2),
)
.unwrap();
} else {
config.ledger.cometbft.proxy_app = TendermintAddress::from_str(
&format!("0.0.0.0:{}", first_port + 2),
)
.unwrap();
}
config.write(&validator_dir, &chain_id, true).unwrap();
},
);
Expand Down

0 comments on commit 7936f71

Please sign in to comment.