Plugin API - add methods returning actual RPC host/port values (#8127)

* deprecate methods returning optionals since we know these will always have a value

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
Sally MacFarlane
2025-03-12 15:52:25 +10:00
committed by GitHub
parent b930bfeeea
commit 35d12070db
5 changed files with 47 additions and 6 deletions

View File

@@ -106,6 +106,8 @@
- Smart-contract-based (onchain) permissioning
- Proof of Work consensus
- Fast Sync
- Plugins
- `BesuConfiguration` methods `getRpcHttpHost` and `getRpcHttpPort` (which return Optionals) have been deprecated in favour of `getConfiguredRpcHttpHost` and `getConfiguredRpcHttpPort` which return the actual values, which will always be populated since these options have defaults. [#8127](https://github.com/hyperledger/besu/pull/8127)
### Additions and Improvements
- Add RPC HTTP options to specify custom truststore and its password [#7978](https://github.com/hyperledger/besu/pull/7978)

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.services;
import org.hyperledger.besu.cli.options.JsonRpcHttpOptions;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
@@ -32,8 +33,8 @@ public class BesuConfigurationImpl implements BesuConfiguration {
// defaults
private MiningConfiguration miningConfiguration;
private Optional<String> rpcHttpHost = Optional.of("http://localhost");
private Optional<Integer> rpcHttpPort = Optional.of(8545);
private String rpcHttpHost = JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;
private Integer rpcHttpPort = JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT;
/** Default Constructor. */
public BesuConfigurationImpl() {}
@@ -74,18 +75,30 @@ public class BesuConfigurationImpl implements BesuConfiguration {
* @return BesuConfigurationImpl instance
*/
public BesuConfigurationImpl withJsonRpcHttpOptions(final JsonRpcHttpOptions rpcHttpOptions) {
this.rpcHttpHost = Optional.ofNullable(rpcHttpOptions.getRpcHttpHost());
this.rpcHttpPort = Optional.ofNullable(rpcHttpOptions.getRpcHttpPort());
this.rpcHttpHost = rpcHttpOptions.getRpcHttpHost();
this.rpcHttpPort = rpcHttpOptions.getRpcHttpPort();
return this;
}
@Deprecated
@Override
public Optional<String> getRpcHttpHost() {
return Optional.of(rpcHttpHost);
}
@Deprecated
@Override
public Optional<Integer> getRpcHttpPort() {
return Optional.of(rpcHttpPort);
}
@Override
public String getConfiguredRpcHttpHost() {
return rpcHttpHost;
}
@Override
public Optional<Integer> getRpcHttpPort() {
public Integer getConfiguredRpcHttpPort() {
return rpcHttpPort;
}

View File

@@ -217,6 +217,16 @@ public abstract class AbstractIsolationTests {
return Optional.empty();
}
@Override
public String getConfiguredRpcHttpHost() {
return "";
}
@Override
public Integer getConfiguredRpcHttpPort() {
return 0;
}
@Override
public Path getStoragePath() {
return tempData.resolve("database");

View File

@@ -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 = 'Mp4ewH82ykJPHzMATeiPenUJ4TTMyDEad1MI8idyhWk='
knownHash = 'lsoaojUhm38o4QxfJW2fky/eEkrtUyprNrwAkfwebe8='
}
check.dependsOn('checkAPIChanges')

View File

@@ -30,6 +30,7 @@ public interface BesuConfiguration extends BesuService {
*
* @return the configured RPC http host.
*/
@Deprecated(since = "25.1.0")
Optional<String> getRpcHttpHost();
/**
@@ -37,8 +38,23 @@ public interface BesuConfiguration extends BesuService {
*
* @return the configured RPC http port.
*/
@Deprecated(since = "25.1.0")
Optional<Integer> getRpcHttpPort();
/**
* Get the configured RPC http host.
*
* @return the configured RPC http host.
*/
String getConfiguredRpcHttpHost();
/**
* Get the configured RPC http port.
*
* @return the configured RPC http port.
*/
Integer getConfiguredRpcHttpPort();
/**
* Location of the working directory of the storage in the file system running the client.
*