Skip to content

Commit f6dec91

Browse files
authored
combine piecelocator endpoints (#408)
1 parent c4bd718 commit f6dec91

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

deps/config/doc_gen.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/config/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ type StorageMarketConfig struct {
645645

646646
// PieceLocator is a list of HTTP url and headers combination to query for a piece for offline deals
647647
// User can run a remote file server which can host all the pieces over the HTTP and supply a reader when requested.
648-
// The server must have 2 endpoints
649-
// 1. /pieces?id=pieceCID responds with 200 if found or 404 if not. Must send header "Content-Length" with file size as value
650-
// 2. /data?id=pieceCID must provide a reader for the requested piece
648+
// The server must support "HEAD" request and "GET" request.
649+
// 1. <URL>?id=pieceCID with "HEAD" request responds with 200 if found or 404 if not. Must send header "Content-Length" with file size as value
650+
// 2. <URL>?id=pieceCID must provide a reader for the requested piece along with header "Content-Length" with file size as value
651651
PieceLocator []PieceLocatorConfig
652652
}
653653

documentation/en/configuration/default-curio-configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ description: The default curio configuration
415415
[Market.StorageMarketConfig]
416416
# PieceLocator is a list of HTTP url and headers combination to query for a piece for offline deals
417417
# User can run a remote file server which can host all the pieces over the HTTP and supply a reader when requested.
418-
# The server must have 2 endpoints
419-
# 1. /pieces?id=pieceCID responds with 200 if found or 404 if not. Must send header "Content-Length" with file size as value
420-
# 2. /data?id=pieceCID must provide a reader for the requested piece
418+
# The server must support "HEAD" request and "GET" request.
419+
# 1. <URL>?id=pieceCID with "HEAD" request responds with 200 if found or 404 if not. Must send header "Content-Length" with file size as value
420+
# 2. <URL>?id=pieceCID must provide a reader for the requested piece along with header "Content-Length" with file size as value
421421
#
422422
# type: []PieceLocatorConfig
423423
#PieceLocator = []

tasks/storage-market/storage_market.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ func (d *CurioStorageDealMarket) findURLForOfflineDeals(ctx context.Context, dea
476476
// Check if We can find the URL for this piece on remote servers
477477
for rUrl, headers := range d.urls {
478478
// Create a new HTTP request
479-
urlString := fmt.Sprintf("%s/pieces?id=%s", rUrl, pcid)
480-
req, err := http.NewRequest(http.MethodGet, urlString, nil)
479+
urlString := fmt.Sprintf("%s?id=%s", rUrl, pcid)
480+
req, err := http.NewRequest(http.MethodHead, urlString, nil)
481481
if err != nil {
482482
return false, xerrors.Errorf("error creating request: %w", err)
483483
}
@@ -513,10 +513,8 @@ func (d *CurioStorageDealMarket) findURLForOfflineDeals(ctx context.Context, dea
513513
return false, xerrors.Errorf("failed to parse the raw size: %w", err)
514514
}
515515

516-
dataUrl := fmt.Sprintf("%s/data?id=%s", rUrl, pcid)
517-
518516
_, err = tx.Exec(`UPDATE market_mk12_deal_pipeline SET url = $1, headers = $2, raw_size = $3, started = TRUE
519-
WHERE uuid = $4 AND started = FALSE`, dataUrl, hdrs, rawSize, deal)
517+
WHERE uuid = $4 AND started = FALSE`, urlString, hdrs, rawSize, deal)
520518
if err != nil {
521519
return false, xerrors.Errorf("store url for piece %s: updating pipeline: %w", pcid, err)
522520
}

0 commit comments

Comments
 (0)