Fix ByHash json parsing

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
pull/4980/head
Simon Dudley 2 years ago
parent 650e70ca34
commit 663e11e2a3
  1. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1.java
  2. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java

@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFac
import org.hyperledger.besu.ethereum.chain.Blockchain;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import io.vertx.core.Vertx;
@ -55,7 +56,10 @@ public class EngineGetPayloadBodiesByHashV1 extends ExecutionEngineJsonRpcMethod
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
engineCallListener.executionEngineCalled();
final Hash[] blockHashes = request.getRequiredParameter(0, Hash[].class);
final List<Hash> blockHashes =
Arrays.stream(request.getRequest().getParams())
.map(Hash.class::cast)
.collect(Collectors.toList());
traceLambda(LOG, "{} parameters: blockHashes {}", () -> getName(), () -> blockHashes);
@ -63,6 +67,6 @@ public class EngineGetPayloadBodiesByHashV1 extends ExecutionEngineJsonRpcMethod
return new JsonRpcSuccessResponse(
request.getRequest().getId(),
blockResultFactory.payloadBodiesCompleteV1(
Arrays.stream(blockHashes).map(blockchain::getBlockBody).collect(Collectors.toList())));
blockHashes.stream().map(blockchain::getBlockBody).collect(Collectors.toList())));
}
}

@ -224,9 +224,7 @@ public class EngineGetPayloadBodiesByHashV1Test {
return method.response(
new JsonRpcRequestContext(
new JsonRpcRequest(
"2.0",
RpcMethod.ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1.getMethodName(),
new Object[] {hashes})));
"2.0", RpcMethod.ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1.getMethodName(), hashes)));
}
private EngineGetPayloadBodiesResultV1 fromSuccessResp(final JsonRpcResponse resp) {

Loading…
Cancel
Save