Expose start and stop synchronization to plugin aPI (#7940)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7945/head
Gabriel-Trintinalia 1 week ago committed by GitHub
parent f08147acef
commit 27592b5299
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 15
      besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java
  3. 2
      plugin-api/build.gradle
  4. 6
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/sync/SynchronizationService.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(),

@ -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<DiffBasedWorldStateProvider> 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();
}
}

@ -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')

@ -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();
}

Loading…
Cancel
Save