diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 1a842acc58..e2c657dd18 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1278,6 +1278,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { besuPluginContext.addService( SynchronizationService.class, new SynchronizationServiceImpl( + besuController.getSynchronizer(), besuController.getProtocolContext(), besuController.getProtocolSchedule(), besuController.getSyncState(), diff --git a/besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java index 2e15e2ab82..cd4f494dc6 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java @@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockImporter; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -45,6 +46,7 @@ public class SynchronizationServiceImpl implements SynchronizationService { private final ProtocolContext protocolContext; private final ProtocolSchedule protocolSchedule; + private final Synchronizer synchronizer; private final SyncState syncState; private final Optional worldStateArchive; @@ -52,16 +54,19 @@ public class SynchronizationServiceImpl implements SynchronizationService { /** * Constructor for SynchronizationServiceImpl. * + * @param synchronizer synchronizer * @param protocolContext protocol context * @param protocolSchedule protocol schedule * @param syncState sync state * @param worldStateArchive world state archive */ public SynchronizationServiceImpl( + final Synchronizer synchronizer, final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, final SyncState syncState, final WorldStateArchive worldStateArchive) { + this.synchronizer = synchronizer; this.protocolContext = protocolContext; this.protocolSchedule = protocolSchedule; this.syncState = syncState; @@ -157,4 +162,14 @@ public class SynchronizationServiceImpl implements SynchronizationService { } }); } + + @Override + public void stop() { + synchronizer.stop(); + } + + @Override + public void start() { + synchronizer.start(); + } } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 6f83363dd4..d504767138 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -71,7 +71,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'KuKoCZT1A+gOlJlry5GQMCRKVWWAlO3lGAqt9MDv0r4=' + knownHash = 'PKvPlngg7BfdZ4Jinh0IUsyFOLvNaQU72VD4BHia/WM=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/sync/SynchronizationService.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/sync/SynchronizationService.java index ad9682429d..1b1ea8bdfe 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/sync/SynchronizationService.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/sync/SynchronizationService.java @@ -59,4 +59,10 @@ public interface SynchronizationService extends BesuService { /** Disables the worldstate trie for update. */ void disableWorldStateTrie(); + + /** Stops the synchronizer. */ + void stop(); + + /** Starts the synchronizer. */ + void start(); }