From 401d3688d00c495c551107d8c54dc83c989d57dc Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 7 Nov 2023 14:28:38 +1100 Subject: [PATCH] feat: expose deal ID as replica ID Closes: https://github.com/filecoin-project/motion/issues/216 --- README.md | 1 + api/model.go | 1 + api/server/handler.go | 1 + blob/blob.go | 5 ++--- integration/singularity/store.go | 1 + openapi.yaml | 6 +++++- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4a6ea8..208b5cf 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ curl http://localhost:40080/v0/blob/ad7ef987-a932-495c-aa0c-7ffcabeda45f/status "id": "ad7ef987-a932-495c-aa0c-7ffcabeda45f", "replicas": [ { + "id": 1, "provider": "f1234", "status": "active", "lastVerified": "2020-12-01T22:48:00Z", diff --git a/api/model.go b/api/model.go index e305268..3f204f9 100644 --- a/api/model.go +++ b/api/model.go @@ -22,6 +22,7 @@ type ( Pieces []Piece `json:"pieces"` } Piece struct { + Id int64 `json:"id"` Expiration time.Time `json:"expiration"` LastVerified time.Time `json:"lastVerified"` PieceCID string `json:"pieceCid"` diff --git a/api/server/handler.go b/api/server/handler.go index b4d3913..b6570df 100644 --- a/api/server/handler.go +++ b/api/server/handler.go @@ -158,6 +158,7 @@ func (m *HttpServer) handleBlobGetStatusByID(w http.ResponseWriter, r *http.Requ apiPieces := make([]api.Piece, 0, len(replica.Pieces)) for _, piece := range replica.Pieces { apiPieces = append(apiPieces, api.Piece{ + Id: piece.Id, Expiration: piece.Expiration, LastVerified: piece.LastUpdated, PieceCID: piece.PieceCID, diff --git a/blob/blob.go b/blob/blob.go index 70bb518..a5fc166 100644 --- a/blob/blob.go +++ b/blob/blob.go @@ -15,9 +15,7 @@ var ( ErrBlobNotFound = errors.New("no blob is found with given ID") ) -var ( - logger = log.Logger("motion/blobstore") -) +var logger = log.Logger("motion/blobstore") type ( // ID uniquely identifies a blob. @@ -37,6 +35,7 @@ type ( Pieces []Piece } Piece struct { + Id int64 Expiration time.Time LastUpdated time.Time PieceCID string diff --git a/integration/singularity/store.go b/integration/singularity/store.go index 3cea49a..7cd2d20 100644 --- a/integration/singularity/store.go +++ b/integration/singularity/store.go @@ -519,6 +519,7 @@ func (s *SingularityStore) Describe(ctx context.Context, id blob.ID) (*blob.Desc updatedAt = time.Time{} } piece := blob.Piece{ + Id: deal.ID, Expiration: epochutil.EpochToTime(int32(deal.EndEpoch)), LastUpdated: updatedAt, PieceCID: deal.PieceCid, diff --git a/openapi.yaml b/openapi.yaml index 8b553a9..8376b8e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -112,6 +112,9 @@ paths: items: type: object properties: + id: + type: integer + description: 'Unique, opaque identifier for the replica.' expiration: type: string format: date-time @@ -133,7 +136,8 @@ paths: replica: provider: 'f0xxxx' pieces: - - expiration: '2023-06-29T00:00:00Z' + - id: 1 + expiration: '2023-06-29T00:00:00Z' lastVerified: '2023-05-29T00:00:00Z' pieceCid: 'baguqexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' status: 'active'