Skip to content

Commit

Permalink
chore: update result info
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisLCrypto committed Nov 24, 2024
1 parent 9d4a6b4 commit 9d8b97c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions blob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package walrus_go
36 changes: 26 additions & 10 deletions walrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@ type StoreOptions struct {

// BlobInfo represents the information returned after storing data
type BlobInfo struct {
BlobID string `json:"blobId"`
BlobID string `json:"blobId"`
EndEpoch int `json:"endEpoch"`
}

// BlobObject represents the blob object information
type BlobObject struct {
ID string `json:"id"`
StoredEpoch int `json:"storedEpoch"`
BlobID string `json:"blobId"`
Size int64 `json:"size"`
ErasureCodeType string `json:"erasureCodeType"`
CertifiedEpoch int `json:"certifiedEpoch"`
Storage StorageInfo `json:"storage"`
}

// StoreResponse represents the unified response for store operations
type StoreResponse struct {
Blob BlobInfo `json:"blobInfo,omitempty"`

// For newly created blobs
NewlyCreated *struct {
BlobObject BlobObject `json:"blobObject"`
Expand All @@ -54,15 +68,17 @@ type StoreResponse struct {
} `json:"alreadyCertified,omitempty"`
}

// BlobObject represents the blob object information
type BlobObject struct {
ID string `json:"id"`
StoredEpoch int `json:"storedEpoch"`
BlobID string `json:"blobId"`
Size int `json:"size"`
ErasureCodeType string `json:"erasureCodeType"`
CertifiedEpoch int `json:"certifiedEpoch"`
Storage StorageInfo `json:"storage"`
// NormalizeBlobResponse is a helper function to normalize the response from the blob service
func (resp *StoreResponse) NormalizeBlobResponse() {
if resp.AlreadyCertified != nil {
resp.Blob.BlobID = resp.AlreadyCertified.BlobID
resp.Blob.EndEpoch = resp.AlreadyCertified.EndEpoch
}

if resp.NewlyCreated != nil {
resp.Blob.BlobID = resp.NewlyCreated.BlobObject.BlobID
resp.Blob.EndEpoch = resp.NewlyCreated.BlobObject.Storage.EndEpoch
}
}

// EventInfo represents the certification event information
Expand Down

0 comments on commit 9d8b97c

Please sign in to comment.