Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add get object from SP #10

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading