Skip to content

Commit

Permalink
staterecovery: disable synch and maining services again on afterExter…
Browse files Browse the repository at this point in the history
…nalServicePostMainLoop callback
  • Loading branch information
jpnovais committed Jan 28, 2025
1 parent 4753f40 commit 11e3b15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ open class LineaStateRecoveryPlugin : BesuPlugin {
}

override fun afterExternalServicePostMainLoop() {
// we need to recall this again because Sync and Mining services
// bay have been started after the plugin start
this.recoveryModeManager.enableRecoveryModeIfNecessary()
}

override fun stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class RecoveryModeManager(

init {
log.info("RecoveryModeManager initializing: headBlockNumber={}", headBlockNumber)
enableRecoveryModeIfNecessary()
}

@Synchronized
fun enableRecoveryModeIfNecessary() {
if (hasReachedTargetBlock()) {
log.info(
"enabling recovery mode immediately at blockNumber={} recoveryTargetBlockNumber={}",
Expand Down Expand Up @@ -92,9 +97,6 @@ class RecoveryModeManager(

/** Switches the node to recovery mode. */
private fun switchToRecoveryMode() {
check(!recoveryModeTriggered.get()) {
"cannot enable already enabled recovery mode"
}
log.warn("Stopping synchronization service")
synchronizationService.stop()

Expand All @@ -105,7 +107,7 @@ class RecoveryModeManager(
miningService.stop()

log.info(
"Switched to state recovery mode at block={}",
"switched to state recovery mode at block={}",
headBlockNumber
)
recoveryModeTriggered.set(true)
Expand Down

0 comments on commit 11e3b15

Please sign in to comment.