Skip to content

Commit

Permalink
Fix ByHash json parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu committed Jan 25, 2023
1 parent 650e70c commit 663e11e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -55,14 +56,17 @@ public String getName() {
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);

final Blockchain blockchain = protocolContext.getBlockchain();
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())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ private JsonRpcResponse resp(final Hash[] hashes) {
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) {
Expand Down

0 comments on commit 663e11e

Please sign in to comment.