Skip to content

Commit

Permalink
combine piecelocator endpoints (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr authored Feb 12, 2025
1 parent c4bd718 commit f6dec91
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions deps/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions deps/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ type StorageMarketConfig struct {

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

Expand Down
6 changes: 3 additions & 3 deletions documentation/en/configuration/default-curio-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ description: The default curio configuration
[Market.StorageMarketConfig]
# PieceLocator is a list of HTTP url and headers combination to query for a piece for offline deals
# User can run a remote file server which can host all the pieces over the HTTP and supply a reader when requested.
# The server must have 2 endpoints
# 1. /pieces?id=pieceCID responds with 200 if found or 404 if not. Must send header "Content-Length" with file size as value
# 2. /data?id=pieceCID must provide a reader for the requested piece
# The server must support "HEAD" request and "GET" request.
# 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
# 2. <URL>?id=pieceCID must provide a reader for the requested piece along with header "Content-Length" with file size as value
#
# type: []PieceLocatorConfig
#PieceLocator = []
Expand Down
8 changes: 3 additions & 5 deletions tasks/storage-market/storage_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ func (d *CurioStorageDealMarket) findURLForOfflineDeals(ctx context.Context, dea
// Check if We can find the URL for this piece on remote servers
for rUrl, headers := range d.urls {
// Create a new HTTP request
urlString := fmt.Sprintf("%s/pieces?id=%s", rUrl, pcid)
req, err := http.NewRequest(http.MethodGet, urlString, nil)
urlString := fmt.Sprintf("%s?id=%s", rUrl, pcid)
req, err := http.NewRequest(http.MethodHead, urlString, nil)
if err != nil {
return false, xerrors.Errorf("error creating request: %w", err)
}
Expand Down Expand Up @@ -513,10 +513,8 @@ func (d *CurioStorageDealMarket) findURLForOfflineDeals(ctx context.Context, dea
return false, xerrors.Errorf("failed to parse the raw size: %w", err)
}

dataUrl := fmt.Sprintf("%s/data?id=%s", rUrl, pcid)

_, err = tx.Exec(`UPDATE market_mk12_deal_pipeline SET url = $1, headers = $2, raw_size = $3, started = TRUE
WHERE uuid = $4 AND started = FALSE`, dataUrl, hdrs, rawSize, deal)
WHERE uuid = $4 AND started = FALSE`, urlString, hdrs, rawSize, deal)
if err != nil {
return false, xerrors.Errorf("store url for piece %s: updating pipeline: %w", pcid, err)
}
Expand Down

0 comments on commit f6dec91

Please sign in to comment.