Skip to content

Commit 7c3ac0d

Browse files
authored
fix: gateway/blocks-backend: GetBlock should not perform IPLD decoding (#845)
* gateway/blocks-backend: GetBlock should not perform IPLD decoding #673
1 parent 7e1c654 commit 7c3ac0d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The following emojis are used to highlight certain changes:
4343

4444
- Fix memory leaks due to not cleaning up wantlists [#829](https://github.com/ipfs/boxo/pull/829), [#833](https://github.com/ipfs/boxo/pull/833)
4545
- `ipns`: Improved interop with legacy clients by restoring support for `[]byte` CID in `Value` field. `Value()` will convert it to a valid `path.Path`. Empty `Value()` will produce `NoopPath` (`/ipfs/bafkqaaa`) to avoid breaking existing code that expects a valid record to always produce a valid content path. [#830](https://github.com/ipfs/boxo/pull/830)
46+
- `gateway/blocks-backend`: Removed IPLD decoding in GetBlock funciton in gateway's BlocksBackend. Now it's querying the blockService directly instead of dagService. [#845](https://github.com/ipfs/boxo/pull/845)
4647

4748

4849
## [v0.27.3]

gateway/backend_blocks.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,25 @@ func (bb *BlocksBackend) GetAll(ctx context.Context, path path.ImmutablePath) (C
211211
}
212212

213213
func (bb *BlocksBackend) GetBlock(ctx context.Context, path path.ImmutablePath) (ContentPathMetadata, files.File, error) {
214-
md, nd, err := bb.getNode(ctx, path)
214+
roots, lastSeg, remainder, err := bb.getPathRoots(ctx, path)
215+
if err != nil {
216+
return ContentPathMetadata{}, nil, err
217+
}
218+
219+
md := ContentPathMetadata{
220+
PathSegmentRoots: roots,
221+
LastSegment: lastSeg,
222+
LastSegmentRemainder: remainder,
223+
}
224+
225+
lastRoot := lastSeg.RootCid()
226+
227+
b, err := bb.blockService.GetBlock(ctx, lastRoot)
215228
if err != nil {
216229
return md, nil, err
217230
}
218231

219-
return md, files.NewBytesFile(nd.RawData()), nil
232+
return md, files.NewBytesFile(b.RawData()), nil
220233
}
221234

222235
func (bb *BlocksBackend) Head(ctx context.Context, path path.ImmutablePath) (ContentPathMetadata, *HeadResponse, error) {

0 commit comments

Comments
 (0)