naming things is important (#7895)

BesuContext was not a helpful name for an interface that only manipulates services to be used by plugins.

---------

Signed-off-by: jflo <justin+github@florentine.us>
main
Justin Florentine 21 hours ago committed by GitHub
parent 9718fd58e7
commit c127f9c1d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java
  3. 6
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java
  4. 8
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java
  5. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java
  6. 10
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
  7. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java
  8. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java
  9. 6
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java
  10. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
  11. 4
      besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java
  12. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java
  13. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/DiffBasedWorldStateProvider.java
  14. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/common/trielog/TrieLogManager.java
  15. 2
      plugin-api/build.gradle
  16. 42
      plugin-api/src/main/java/org/hyperledger/besu/plugin/BesuContext.java
  17. 2
      plugin-api/src/main/java/org/hyperledger/besu/plugin/BesuPlugin.java
  18. 55
      plugin-api/src/main/java/org/hyperledger/besu/plugin/ServiceManager.java
  19. 6
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/BesuService.java
  20. 6
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBPlugin.java
  21. 6
      services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/InMemoryStoragePlugin.java

@ -6,6 +6,7 @@
- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783) - Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
### Upcoming Breaking Changes ### Upcoming Breaking Changes
- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge` - `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
### Additions and Improvements ### Additions and Improvements

@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File; import java.io.File;
@ -39,7 +39,7 @@ public class BadCLIOptionsPlugin implements BesuPlugin {
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.info("Registering BadCliOptionsPlugin"); LOG.info("Registering BadCliOptionsPlugin");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins")); callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));
writeStatus("init"); writeStatus("init");

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockHeader; import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.data.PropagatedBlockContext; import org.hyperledger.besu.plugin.data.PropagatedBlockContext;
import org.hyperledger.besu.plugin.services.BesuEvents; import org.hyperledger.besu.plugin.services.BesuEvents;
@ -35,14 +35,14 @@ import org.slf4j.LoggerFactory;
public class TestBesuEventsPlugin implements BesuPlugin { public class TestBesuEventsPlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class); private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class);
private BesuContext context; private ServiceManager context;
private Optional<Long> subscriptionId; private Optional<Long> subscriptionId;
private final AtomicInteger blockCounter = new AtomicInteger(); private final AtomicInteger blockCounter = new AtomicInteger();
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
this.context = context; this.context = context;
LOG.info("Registered"); LOG.info("Registered");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins")); callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));

@ -17,8 +17,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockContext; import org.hyperledger.besu.plugin.data.BlockContext;
import org.hyperledger.besu.plugin.services.BlockchainService; import org.hyperledger.besu.plugin.services.BlockchainService;
import org.hyperledger.besu.plugin.services.RpcEndpointService; import org.hyperledger.besu.plugin.services.RpcEndpointService;
@ -40,11 +40,11 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
private static final String RPC_METHOD_SAFE_BLOCK = "updateSafeBlockV1"; private static final String RPC_METHOD_SAFE_BLOCK = "updateSafeBlockV1";
@Override @Override
public void register(final BesuContext besuContext) { public void register(final ServiceManager serviceManager) {
LOG.trace("Registering plugin ..."); LOG.trace("Registering plugin ...");
final RpcEndpointService rpcEndpointService = final RpcEndpointService rpcEndpointService =
besuContext serviceManager
.getService(RpcEndpointService.class) .getService(RpcEndpointService.class)
.orElseThrow( .orElseThrow(
() -> () ->
@ -52,7 +52,7 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
"Failed to obtain RpcEndpointService from the BesuContext.")); "Failed to obtain RpcEndpointService from the BesuContext."));
final BlockchainService blockchainService = final BlockchainService blockchainService =
besuContext serviceManager
.getService(BlockchainService.class) .getService(BlockchainService.class)
.orElseThrow( .orElseThrow(
() -> () ->

@ -15,8 +15,8 @@
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.RpcEndpointService; import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
@ -36,7 +36,7 @@ public class TestInProcessRpcServicePlugin implements BesuPlugin {
long minGasPrice = -1; long minGasPrice = -1;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
final PicoCLIOptions cmdlineOptions = final PicoCLIOptions cmdlineOptions =
context context
.getService(PicoCLIOptions.class) .getService(PicoCLIOptions.class)

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory; import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
@ -30,12 +30,12 @@ import org.slf4j.LoggerFactory;
@AutoService(BesuPlugin.class) @AutoService(BesuPlugin.class)
public class TestMetricsPlugin implements BesuPlugin { public class TestMetricsPlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestMetricsPlugin.class); private static final Logger LOG = LoggerFactory.getLogger(TestMetricsPlugin.class);
private BesuContext besuContext; private ServiceManager serviceManager;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.info("Registering TestMetricsPlugin"); LOG.info("Registering TestMetricsPlugin");
besuContext = context; serviceManager = context;
context context
.getService(MetricCategoryRegistry.class) .getService(MetricCategoryRegistry.class)
.orElseThrow() .orElseThrow()
@ -45,7 +45,7 @@ public class TestMetricsPlugin implements BesuPlugin {
@Override @Override
public void start() { public void start() {
LOG.info("Starting TestMetricsPlugin"); LOG.info("Starting TestMetricsPlugin");
besuContext serviceManager
.getService(MetricsSystem.class) .getService(MetricsSystem.class)
.orElseThrow() .orElseThrow()
.createGauge( .createGauge(

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PermissioningService; import org.hyperledger.besu.plugin.services.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
@ -40,7 +40,7 @@ public class TestPermissioningPlugin implements BesuPlugin {
PermissioningService service; PermissioningService service;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this); context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this);
service = context.getService(PermissioningService.class).orElseThrow(); service = context.getService(PermissioningService.class).orElseThrow();
} }

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File; import java.io.File;
@ -57,7 +57,7 @@ public class TestPicoCLIPlugin implements BesuPlugin {
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.info("Registering. Test Option is '{}'", testOption); LOG.info("Registering. Test Option is '{}'", testOption);
state = "registering"; state = "registering";

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PrivacyPluginService; import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyGroupGenesisProvider; import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyGroupGenesisProvider;
@ -32,7 +32,7 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyServicePlugin.class); private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyServicePlugin.class);
PrivacyPluginService pluginService; PrivacyPluginService pluginService;
BesuContext context; ServiceManager context;
TestPrivacyGroupGenesisProvider privacyGroupGenesisProvider = TestPrivacyGroupGenesisProvider privacyGroupGenesisProvider =
new TestPrivacyGroupGenesisProvider(); new TestPrivacyGroupGenesisProvider();
@ -40,7 +40,7 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
new TestSigningPrivateMarkerTransactionFactory(); new TestSigningPrivateMarkerTransactionFactory();
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
this.context = context; this.context = context;
context context

@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.RpcEndpointService; import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest; import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest;
@ -51,7 +51,7 @@ public class TestRpcEndpointServicePlugin implements BesuPlugin {
} }
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
context context
.getService(RpcEndpointService.class) .getService(RpcEndpointService.class)
.ifPresent( .ifPresent(

@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.BesuService; import org.hyperledger.besu.plugin.services.BesuService;
import org.hyperledger.besu.plugin.services.PluginVersionsProvider; import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
@ -49,7 +49,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** The Besu plugin context implementation. */ /** The Besu plugin context implementation. */
public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvider { public class BesuPluginContextImpl implements ServiceManager, PluginVersionsProvider {
private static final Logger LOG = LoggerFactory.getLogger(BesuPluginContextImpl.class); private static final Logger LOG = LoggerFactory.getLogger(BesuPluginContextImpl.class);

@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWo
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.plugin.BesuContext; import org.hyperledger.besu.plugin.ServiceManager;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
@ -52,7 +52,7 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider {
final Blockchain blockchain, final Blockchain blockchain,
final Optional<Long> maxLayersToLoad, final Optional<Long> maxLayersToLoad,
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader, final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
final BesuContext pluginContext, final ServiceManager pluginContext,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final Supplier<WorldStateHealer> worldStateHealerSupplier) { final Supplier<WorldStateHealer> worldStateHealerSupplier) {
super(worldStateKeyValueStorage, blockchain, maxLayersToLoad, pluginContext); super(worldStateKeyValueStorage, blockchain, maxLayersToLoad, pluginContext);

@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.plugin.BesuContext; import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog; import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import java.util.ArrayList; import java.util.ArrayList;
@ -61,7 +61,7 @@ public abstract class DiffBasedWorldStateProvider implements WorldStateArchive {
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage, final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
final Blockchain blockchain, final Blockchain blockchain,
final Optional<Long> maxLayersToLoad, final Optional<Long> maxLayersToLoad,
final BesuContext pluginContext) { final ServiceManager pluginContext) {
this.worldStateKeyValueStorage = worldStateKeyValueStorage; this.worldStateKeyValueStorage = worldStateKeyValueStorage;
// TODO: de-dup constructors // TODO: de-dup constructors

@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog.TrieLogFactor
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState; import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator; import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.accumulator.DiffBasedWorldStateUpdateAccumulator;
import org.hyperledger.besu.plugin.BesuContext; import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.TrieLogService; import org.hyperledger.besu.plugin.services.TrieLogService;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog; import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import org.hyperledger.besu.plugin.services.trielogs.TrieLogEvent; import org.hyperledger.besu.plugin.services.trielogs.TrieLogEvent;
@ -53,7 +53,7 @@ public class TrieLogManager {
final Blockchain blockchain, final Blockchain blockchain,
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage, final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
final long maxLayersToLoad, final long maxLayersToLoad,
final BesuContext pluginContext) { final ServiceManager pluginContext) {
this.blockchain = blockchain; this.blockchain = blockchain;
this.rootWorldStateStorage = worldStateKeyValueStorage; this.rootWorldStateStorage = worldStateKeyValueStorage;
this.maxLayersToLoad = maxLayersToLoad; this.maxLayersToLoad = maxLayersToLoad;
@ -133,7 +133,7 @@ public class TrieLogManager {
trieLogObservers.unsubscribe(id); trieLogObservers.unsubscribe(id);
} }
private TrieLogFactory setupTrieLogFactory(final BesuContext pluginContext) { private TrieLogFactory setupTrieLogFactory(final ServiceManager pluginContext) {
// if we have a TrieLogService from pluginContext, use it. // if we have a TrieLogService from pluginContext, use it.
var trieLogServicez = var trieLogServicez =
Optional.ofNullable(pluginContext) Optional.ofNullable(pluginContext)

@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) { tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought" description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files files = sourceSets.main.allJava.files
knownHash = 'ktVrmQXU7LMQi1ieb9OQ2vJNqZ0SVQ7Usauh1LMvUXY=' knownHash = 'wOjR3/uPElPs1GonuLMBWStn1zukFMyy/GfQ9OYChpI='
} }
check.dependsOn('checkAPIChanges') check.dependsOn('checkAPIChanges')

@ -14,42 +14,6 @@
*/ */
package org.hyperledger.besu.plugin; package org.hyperledger.besu.plugin;
import org.hyperledger.besu.plugin.services.BesuService; /** Deprecated in favor of the more precisely named ServiceManager interface. */
@Deprecated(since = "24.11.0", forRemoval = true)
import java.util.Optional; public interface BesuContext extends ServiceManager {}
/** Allows plugins to access Besu services. */
public interface BesuContext {
/**
* Add service.
*
* @param <T> the type parameter
* @param serviceType the service type
* @param service the service
*/
<T extends BesuService> void addService(final Class<T> serviceType, final T service);
/**
* Get the requested service, if it is available. There are a number of reasons that a service may
* not be available:
*
* <ul>
* <li>The service may not have started yet. Most services are not available before the {@link
* BesuPlugin#start()} method is called
* <li>The service is not supported by this version of Besu
* <li>The service may not be applicable to the current configuration. For example some services
* may only be available when a proof of authority network is in use
* </ul>
*
* <p>Since plugins are automatically loaded, unless the user has specifically requested
* functionality provided by the plugin, no error should be raised if required services are
* unavailable.
*
* @param serviceType the class defining the requested service.
* @param <T> the service type
* @return an optional containing the instance of the requested service, or empty if the service
* is unavailable
*/
<T extends BesuService> Optional<T> getService(Class<T> serviceType);
}

@ -48,7 +48,7 @@ public interface BesuPlugin {
* *
* @param context the context that provides access to Besu services. * @param context the context that provides access to Besu services.
*/ */
void register(BesuContext context); void register(ServiceManager context);
/** /**
* Called once when besu has loaded configuration but before external services have been started * Called once when besu has loaded configuration but before external services have been started

@ -0,0 +1,55 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.plugin;
import org.hyperledger.besu.plugin.services.BesuService;
import java.util.Optional;
/** Adds and accesses BesuServices for plugins to provide or use. */
public interface ServiceManager {
/**
* Add service. Used by core besu or other plugins to add services to the service manager.
*
* @param <T> the type parameter
* @param serviceType the service type
* @param service the service
*/
<T extends BesuService> void addService(final Class<T> serviceType, final T service);
/**
* Get the requested service, if it is available. There are a number of reasons that a service may
* not be available:
*
* <ul>
* <li>The service may not have started yet. Most services are not available before the {@link
* BesuPlugin#start()} method is called
* <li>The service is not supported by this version of Besu
* <li>The service may not be applicable to the current configuration. For example some services
* may only be available when a proof of authority network is in use, or when user provided.
* </ul>
*
* <p>Since plugins are automatically loaded, unless the user has specifically requested
* functionality provided by the plugin, no error should be raised if required services are
* unavailable.
*
* @param serviceType the class defining the requested service.
* @param <T> the service type
* @return an optional containing the instance of the requested service, or empty if the service
* is unavailable
*/
<T extends BesuService> Optional<T> getService(Class<T> serviceType);
}

@ -14,10 +14,10 @@
*/ */
package org.hyperledger.besu.plugin.services; package org.hyperledger.besu.plugin.services;
import org.hyperledger.besu.plugin.BesuContext; import org.hyperledger.besu.plugin.ServiceManager;
/** /**
* All services that can be resolved via {@link BesuContext#getService(Class)} must implement {@link * All services that can be resolved via {@link ServiceManager#getService(Class)} must implement
* BesuService} * {@link BesuService}
*/ */
public interface BesuService {} public interface BesuService {}

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.plugin.services.storage.rocksdb; package org.hyperledger.besu.plugin.services.storage.rocksdb;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.StorageService; import org.hyperledger.besu.plugin.services.StorageService;
import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier; import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;
@ -40,7 +40,7 @@ public class RocksDBPlugin implements BesuPlugin {
private final RocksDBCLIOptions options; private final RocksDBCLIOptions options;
private final List<SegmentIdentifier> ignorableSegments = new ArrayList<>(); private final List<SegmentIdentifier> ignorableSegments = new ArrayList<>();
private BesuContext context; private ServiceManager context;
private RocksDBKeyValueStorageFactory factory; private RocksDBKeyValueStorageFactory factory;
private RocksDBKeyValuePrivacyStorageFactory privacyFactory; private RocksDBKeyValuePrivacyStorageFactory privacyFactory;
@ -59,7 +59,7 @@ public class RocksDBPlugin implements BesuPlugin {
} }
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.debug("Registering plugin"); LOG.debug("Registering plugin");
this.context = context; this.context = context;

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.services.kvstore; package org.hyperledger.besu.services.kvstore;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.BesuConfiguration; import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.StorageService; import org.hyperledger.besu.plugin.services.StorageService;
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
public class InMemoryStoragePlugin implements BesuPlugin { public class InMemoryStoragePlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryStoragePlugin.class); private static final Logger LOG = LoggerFactory.getLogger(InMemoryStoragePlugin.class);
private BesuContext context; private ServiceManager context;
private InMemoryKeyValueStorageFactory factory; private InMemoryKeyValueStorageFactory factory;
private InMemoryKeyValueStorageFactory privacyFactory; private InMemoryKeyValueStorageFactory privacyFactory;
@ -44,7 +44,7 @@ public class InMemoryStoragePlugin implements BesuPlugin {
public InMemoryStoragePlugin() {} public InMemoryStoragePlugin() {}
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.debug("Registering plugin"); LOG.debug("Registering plugin");
this.context = context; this.context = context;

Loading…
Cancel
Save