diff --git a/core/src/main/java/tech/pegasys/web3signer/core/routes/eth2/CommitBoostPublicKeysRoute.java b/core/src/main/java/tech/pegasys/web3signer/core/routes/eth2/CommitBoostPublicKeysRoute.java index 261290049..abdc3cb47 100644 --- a/core/src/main/java/tech/pegasys/web3signer/core/routes/eth2/CommitBoostPublicKeysRoute.java +++ b/core/src/main/java/tech/pegasys/web3signer/core/routes/eth2/CommitBoostPublicKeysRoute.java @@ -15,6 +15,8 @@ import tech.pegasys.web3signer.core.Context; import tech.pegasys.web3signer.core.routes.Web3SignerRoute; import tech.pegasys.web3signer.core.service.http.handlers.commitboost.CommitBoostPublicKeysHandler; +import tech.pegasys.web3signer.signing.ArtifactSignerProvider; +import tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider; import io.vertx.core.http.HttpMethod; import io.vertx.core.json.JsonObject; @@ -23,9 +25,16 @@ public class CommitBoostPublicKeysRoute implements Web3SignerRoute { private static final String PATH = "/signer/v1/get_pubkeys"; private final Context context; + private final ArtifactSignerProvider artifactSignerProvider; public CommitBoostPublicKeysRoute(final Context context) { this.context = context; + // there should be only one DefaultArtifactSignerProvider in eth2 mode + artifactSignerProvider = + context.getArtifactSignerProviders().stream() + .filter(p -> p instanceof DefaultArtifactSignerProvider) + .findFirst() + .orElseThrow(); } @Override @@ -36,7 +45,7 @@ public void register() { .produces(JSON_HEADER) .handler( new BlockingHandlerDecorator( - new CommitBoostPublicKeysHandler(context.getArtifactSignerProviders()), false)) + new CommitBoostPublicKeysHandler(artifactSignerProvider), false)) .failureHandler(context.getErrorHandler()) .failureHandler( ctx -> { diff --git a/core/src/main/java/tech/pegasys/web3signer/core/service/http/handlers/commitboost/CommitBoostPublicKeysHandler.java b/core/src/main/java/tech/pegasys/web3signer/core/service/http/handlers/commitboost/CommitBoostPublicKeysHandler.java index 623cb73e3..95820e4d8 100644 --- a/core/src/main/java/tech/pegasys/web3signer/core/service/http/handlers/commitboost/CommitBoostPublicKeysHandler.java +++ b/core/src/main/java/tech/pegasys/web3signer/core/service/http/handlers/commitboost/CommitBoostPublicKeysHandler.java @@ -20,9 +20,7 @@ import tech.pegasys.web3signer.core.service.http.handlers.commitboost.json.PublicKeysResponse; import tech.pegasys.web3signer.signing.ArtifactSignerProvider; import tech.pegasys.web3signer.signing.KeyType; -import tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -36,22 +34,15 @@ public class CommitBoostPublicKeysHandler implements Handler { private static final Logger LOG = LogManager.getLogger(); - private final List artifactSignerProviders; + private final ArtifactSignerProvider artifactSignerProvider; private final ObjectMapper objectMapper = SigningObjectMapperFactory.createObjectMapper(); - public CommitBoostPublicKeysHandler(final List artifactSignerProviders) { - this.artifactSignerProviders = artifactSignerProviders; + public CommitBoostPublicKeysHandler(final ArtifactSignerProvider artifactSignerProvider) { + this.artifactSignerProvider = artifactSignerProvider; } @Override public void handle(final RoutingContext context) { - // obtain DefaultArtifactSignerProvider as that is the only one we are dealing in eth2 mode. - final ArtifactSignerProvider artifactSignerProvider = - artifactSignerProviders.stream() - .filter(provider -> provider instanceof DefaultArtifactSignerProvider) - .findFirst() - .orElseThrow(); - final PublicKeysResponse publicKeysResponse = toPublicKeysResponse(artifactSignerProvider); try { final String jsonEncoded = objectMapper.writeValueAsString(publicKeysResponse);