fix(core): always set p2p port in non-dev mode (#1919)

* 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.
This commit is contained in:
Dan Cline 2022-12-02 15:11:31 -05:00 committed by GitHub
parent c4e09f261e
commit 5af2800f15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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 {