Skip to content

Commit

Permalink
Expose start and stop synchronization to plugin aPI (#7940)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored Nov 26, 2024
1 parent f08147a commit 27592b5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ private void startPlugins(final Runner runner) {
besuPluginContext.addService(
SynchronizationService.class,
new SynchronizationServiceImpl(
besuController.getSynchronizer(),
besuController.getProtocolContext(),
besuController.getProtocolSchedule(),
besuController.getSyncState(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand All @@ -45,23 +46,27 @@ 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;

/**
* 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;
Expand Down Expand Up @@ -157,4 +162,14 @@ public void disableWorldStateTrie() {
}
});
}

@Override
public void stop() {
synchronizer.stop();
}

@Override
public void start() {
synchronizer.start();
}
}
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 27592b5

Please sign in to comment.