Fix GetBlobBundleV1 response (#5075)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/5071/head^2
Fabio Di Fabio 2 years ago committed by GitHub
parent 8f2f94b6ea
commit 031db82bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetBlobsBundleV1.java
  2. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlobsBundleV1.java

@ -63,20 +63,23 @@ public class EngineGetBlobsBundleV1 extends AbstractEngineGetPayload {
private BlobsBundleV1 createResponse(final Block block) { private BlobsBundleV1 createResponse(final Block block) {
List<Bytes> kzgs = final List<Transaction.BlobsWithCommitments> blobsWithCommitments =
block.getBody().getTransactions().stream() block.getBody().getTransactions().stream()
.map(Transaction::getBlobsWithCommitments) .map(Transaction::getBlobsWithCommitments)
.filter(Optional::isPresent) .filter(Optional::isPresent)
.map(Optional::get) .map(Optional::get)
.collect(Collectors.toList());
final List<String> kzgs =
blobsWithCommitments.stream()
.flatMap(b -> b.getKzgCommitments().stream()) .flatMap(b -> b.getKzgCommitments().stream())
.map(Bytes::toString)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Bytes> blobs = final List<String> blobs =
block.getBody().getTransactions().stream() blobsWithCommitments.stream()
.map(Transaction::getBlobsWithCommitments)
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(b -> b.getBlobs().stream()) .flatMap(b -> b.getBlobs().stream())
.map(Bytes::toString)
.collect(Collectors.toList()); .collect(Collectors.toList());
return new BlobsBundleV1(block.getHash(), kzgs, blobs); return new BlobsBundleV1(block.getHash(), kzgs, blobs);

@ -21,18 +21,17 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.tuweni.bytes.Bytes;
@JsonPropertyOrder({"blockHash", "kzgs", "blobs"}) @JsonPropertyOrder({"blockHash", "kzgs", "blobs"})
public class BlobsBundleV1 { public class BlobsBundleV1 {
private final String blockHash; private final String blockHash;
private final List<Bytes> kzgs; private final List<String> kzgs;
private final List<Bytes> blobs; private final List<String> blobs;
public BlobsBundleV1(final Hash blockHash, final List<Bytes> kzgs, final List<Bytes> blobs) { public BlobsBundleV1(final Hash blockHash, final List<String> kzgs, final List<String> blobs) {
this.blockHash = blockHash.toString(); this.blockHash = blockHash.toString();
this.kzgs = kzgs; this.kzgs = kzgs;
this.blobs = blobs; this.blobs = blobs;
@ -44,12 +43,12 @@ public class BlobsBundleV1 {
} }
@JsonGetter("kzgs") @JsonGetter("kzgs")
public List<Bytes> getKzgs() { public List<String> getKzgs() {
return kzgs; return kzgs;
} }
@JsonGetter("blobs") @JsonGetter("blobs")
public List<Bytes> getBlobs() { public List<String> getBlobs() {
return blobs; return blobs;
} }
} }

Loading…
Cancel
Save