Skip to content

Commit

Permalink
feat: add get object from SP
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Jul 17, 2024
1 parent fc9f433 commit 4037375
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions external/cmn/sp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmn
import (
"context"
"encoding/xml"
"io"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -61,3 +62,19 @@ func (c *SPClient) GetBucketReadQuota(ctx context.Context, bucketName string) (Q
}
return QuotaResult, nil
}

func (c *SPClient) GetBundleObject(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error) {
var urlStr string
parts := strings.Split(c.host, "//")
urlStr = parts[0] + "//" + bucketName + "." + parts[1] + "/" + objectName

req, err := http.NewRequestWithContext(ctx, http.MethodGet, urlStr, nil)
if err != nil {
return nil, err
}
resp, err := c.hc.Do(req)
if err != nil {
return nil, err
}
return resp.Body, nil
}
4 changes: 2 additions & 2 deletions syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *BlobSyncer) sync() error {
var latestBlockResp *structs.GetBlockV2Response
block, err = s.client.GetBeaconBlock(ctx, blockID)
if err != nil {
if err != eth.ErrBlockNotFound {
if !errors.Is(err, eth.ErrBlockNotFound) {
return err
}
// Both try to get forked block and non-exist block will return 404. When the response is ErrBlockNotFound,
Expand Down Expand Up @@ -217,7 +217,7 @@ func (s *BlobSyncer) sync() error {
dbErr = err
}
if dbErr != nil {
logging.Logger.Errorf("failed to save block(h=%d) to DB, err=%s", blockID, err.Error())
logging.Logger.Errorf("failed to save block(h=%d) to DB, err=%s", blockID, dbErr.Error())
return dbErr
}
if blockID == s.bundleDetail.finalizeBlockID {
Expand Down

0 comments on commit 4037375

Please sign in to comment.