ipfs/boxo

gateway/blocks-backend: GetBlock should not perform IPLD decoding

Opened this issue · 1 comments

The gateway BlocksBackend's GetBlock function under the hood uses the dagservice's Get function which means it attempts to do an IPLD decoding of the block. This is not good because it means the gateway needs to understand the blocks codec in order to return it even when it doesn't really need to.

func (bb *BlocksBackend) GetBlock(ctx context.Context, path path.ImmutablePath) (ContentPathMetadata, files.File, error) {

nd, err := bb.dagService.Get(ctx, lastRoot)

As an example: rainbow does not support dag-jose and so sending a format=raw request to a rainbow gateway will fail even though it could pass.

A fix here is to use the blockservice directly instead of the dagservice for the GetBlock function's retrieval purposes after doing any path traversals required to get to the final block.

Do we still need dagservice to determine if a directory is being read?