Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/graph_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,16 @@ func (api *GraphGateway) Get(ctx context.Context, path gateway.ImmutablePath, by
carParams := "?format=car&depth=1"

// fetch CAR with &bytes= to get minimal set of blocks for the request
// Note: majority of requests have 0 or max 1 ranges. if there are more ranges than one,
// that is a niche edge cache we don't prefetch as CAR and use fallback blockstore instead.
if rangeCount > 0 {
bytesBuilder := strings.Builder{}
bytesBuilder.WriteString("&bytes=")
for i, r := range byteRanges {
bytesBuilder.WriteString(strconv.FormatUint(r.From, 10))
bytesBuilder.WriteString("-")
if r.To != nil {
bytesBuilder.WriteString(strconv.FormatInt(*r.To, 10))
}
if i != rangeCount-1 {
bytesBuilder.WriteString(",")
}
r := byteRanges[0]
bytesBuilder.WriteString(strconv.FormatUint(r.From, 10))
bytesBuilder.WriteString(":")
if r.To != nil {
bytesBuilder.WriteString(strconv.FormatInt(*r.To, 10))
}
carParams += bytesBuilder.String()
}
Expand Down