Skip to content

Commit

Permalink
Fix GetBlobBundleV1 response (hyperledger#5075)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
(cherry picked from commit 031db82)
(cherry picked from commit de9875b00e72c018603885fa3c68142e828d9a06)
  • Loading branch information
fab-10 authored and jflo committed May 24, 2023
1 parent adf1da6 commit f9ea8be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ protected JsonRpcResponse createResponse(

private BlobsBundleV1 createResponse(final Block block) {

List<Bytes> kzgs =
final List<Transaction.BlobsWithCommitments> blobsWithCommitments =
block.getBody().getTransactions().stream()
.map(Transaction::getBlobsWithCommitments)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());

final List<String> kzgs =
blobsWithCommitments.stream()
.flatMap(b -> b.getKzgCommitments().stream())
.map(Bytes::toString)
.collect(Collectors.toList());

List<Bytes> blobs =
block.getBody().getTransactions().stream()
.map(Transaction::getBlobsWithCommitments)
.filter(Optional::isPresent)
.map(Optional::get)
final List<String> blobs =
blobsWithCommitments.stream()
.flatMap(b -> b.getBlobs().stream())
.map(Bytes::toString)
.collect(Collectors.toList());

return new BlobsBundleV1(block.getHash(), kzgs, blobs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.tuweni.bytes.Bytes;

@JsonPropertyOrder({"blockHash", "kzgs", "blobs"})
public class BlobsBundleV1 {

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.kzgs = kzgs;
this.blobs = blobs;
Expand All @@ -44,12 +43,12 @@ public String getBlockHash() {
}

@JsonGetter("kzgs")
public List<Bytes> getKzgs() {
public List<String> getKzgs() {
return kzgs;
}

@JsonGetter("blobs")
public List<Bytes> getBlobs() {
public List<String> getBlobs() {
return blobs;
}
}

0 comments on commit f9ea8be

Please sign in to comment.