Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(core): always set p2p port in non-dev mode (#1919)
Browse files Browse the repository at this point in the history
* if geth is in non-dev mode, it has been explicitly set by either
   disabling discovery or setting a p2p port. To prevent geth from
   crashing if another process is using the default p2p port, always set
   the p2p port if geth is in non-dev mode.
  • Loading branch information
Rjected authored Dec 2, 2022
1 parent c4e09f2 commit 5af2800
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ethers-core/src/utils/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ impl Geth {
}
}
GethMode::NonDev(PrivateNetOptions { p2p_port, discovery }) => {
if let Some(p2p_port) = p2p_port {
cmd.arg("--port").arg(p2p_port.to_string());
}
// automatically enable and set the p2p port if we are in non-dev mode
let port = if let Some(port) = p2p_port { port } else { unused_port() };
cmd.arg("--port").arg(port.to_string());

// disable discovery if the flag is set
if !discovery {
Expand Down

0 comments on commit 5af2800

Please sign in to comment.