Interface BesuPlugin
public interface BesuPlugin
Base interface for Besu plugins.
Plugins are discovered and loaded using ServiceLoader from jar files within
Besu's plugin directory. See the ServiceLoader documentation for how to
register plugins.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidHook to execute plugin setup code after external servicesdefault voidCalled once when besu has loaded configuration but before external services have been started e.g.default StringgetName()Returns the name of the plugin.default StringRetrieves the version information of the plugin.voidregister(ServiceManager context) Called when the plugin is first registered with Besu.default CompletableFuture<Void> Called when the plugin is being reloaded.voidstart()Called once Besu has loaded configuration and has started external services but before the main loop is up.voidstop()Called when the plugin is being stopped.
-
Method Details
-
getName
Returns the name of the plugin. This name is used to trigger specific actions on individual plugins.- Returns:
- the name of the plugin.
-
register
Called when the plugin is first registered with Besu. Plugins are registered very early in the Besu life-cycle and should use this callback to register any command line options required via the PicoCLIOptions service.The
contextparameter should be stored in a field in the plugin. This is the only time it will be provided to the plugin and is how the plugin will interact with Besu.Typically the plugin will not begin operation until the
start()method is called.- Parameters:
context- the context that provides access to Besu services.
-
beforeExternalServices
default void beforeExternalServices()Called once when besu has loaded configuration but before external services have been started e.g. metrics and http -
start
void start()Called once Besu has loaded configuration and has started external services but before the main loop is up. The plugin should begin operation, including registering any event listener with Besu services and starting any background threads the plugin requires. -
afterExternalServicePostMainLoop
default void afterExternalServicePostMainLoop()Hook to execute plugin setup code after external services -
reloadConfiguration
Called when the plugin is being reloaded. This method will be called through a dedicated JSON RPC endpoint. If not overridden this method does nothing for convenience. The plugin should only implement this method if it supports dynamic reloading.The plugin should reload its configuration dynamically or do nothing if not applicable.
- Returns:
- a
CompletableFuture
-
stop
void stop()Called when the plugin is being stopped. This method will be called as part of Besu shutting down but may also be called at other times to disable the plugin.The plugin should remove any registered listeners and stop any background threads it started.
-
getVersion
Retrieves the version information of the plugin. It constructs a version string using the implementation title and version from the package information. If either the title or version is not available, it defaults to "Unknown Implementation Title" and "Unknown Version", respectively.- Returns:
- A string representing the plugin's version information, formatted as "Title/vVersion".
-