Skip to content

Commit

Permalink
fix:fix p2p network start bug
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <[email protected]>
  • Loading branch information
GrapeBaBa committed Dec 7, 2023
1 parent ed15506 commit c0d6d43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hildr-node/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

group 'me.grapebaba'
version '0.2.0'
version '0.2.1'

repositories {
// Use Maven Central for resolving dependencies.
Expand Down
12 changes: 7 additions & 5 deletions hildr-node/src/main/java/io/optimism/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public class Driver<E extends Engine> extends AbstractExecutionThreadService {

private RollupConfigResult cachedRollConfig;

private OpStackNetwork opStackNetwork;
private final OpStackNetwork opStackNetwork;

private volatile boolean isP2PNetworkStarted;

/**
* Instantiates a new Driver.
Expand All @@ -127,7 +129,6 @@ public class Driver<E extends Engine> extends AbstractExecutionThreadService {
* @param latch the close notifier
* @param config the chain config
* @param opStackNetwork the op stack network
*
*/
@SuppressWarnings("preview")
public Driver(
Expand Down Expand Up @@ -371,11 +372,10 @@ protected void shutDown() {
LOGGER.info("engineDriver shut down.");
this.rpcServer.stop();
LOGGER.info("driver stopped.");
if (this.opStackNetwork != null) {
if (this.opStackNetwork != null && this.isP2PNetworkStarted) {
this.opStackNetwork.stop();
LOGGER.info("opStackNetwork stopped.");
}
this.tryStartNetwork();
}

@Override
Expand Down Expand Up @@ -414,6 +414,8 @@ private void advance() throws InterruptedException, ExecutionException {
}
this.updateFinalized();
this.updateMetrics();

this.tryStartNetwork();
}

private void advanceSafeHead() throws ExecutionException, InterruptedException {
Expand Down Expand Up @@ -563,7 +565,7 @@ private boolean synced() {
}

private void tryStartNetwork() {
if (this.synced() && this.opStackNetwork != null) {
if (this.synced() && this.opStackNetwork != null && !this.isP2PNetworkStarted) {
this.opStackNetwork.start();
}
}
Expand Down

0 comments on commit c0d6d43

Please sign in to comment.