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

fix: Use the unified piecestorage object #409

Merged
merged 1 commit into from
Aug 15, 2023
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
5 changes: 1 addition & 4 deletions cmd/droplet/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ func runDaemon(cctx *cli.Context) error {
if err = router.Handle("/resource", rpc.NewPieceStorageServer(resAPI.PieceStorageMgr)).GetError(); err != nil {
return fmt.Errorf("handle 'resource' failed: %w", err)
}
httpRetrievalServer, err := httpretrieval.NewServer(&cfg.PieceStorage)
if err != nil {
return err
}
httpRetrievalServer := httpretrieval.NewServer(resAPI.PieceStorageMgr)

var iMarket marketapiV1.IMarketStruct
permission.PermissionProxy(marketapiV1.IMarket(resAPI), &iMarket)
Expand Down
11 changes: 2 additions & 9 deletions retrievalprovider/httpretrieval/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/NYTimes/gziphandler"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/ipfs-force-community/droplet/v2/config"
"github.com/ipfs-force-community/droplet/v2/piecestorage"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
Expand All @@ -19,17 +18,11 @@ import (
var log = logging.Logger("httpserver")

type Server struct {
// path string
pieceMgr *piecestorage.PieceStorageManager
}

func NewServer(cfg *config.PieceStorage) (*Server, error) {
pieceMgr, err := piecestorage.NewPieceStorageManager(cfg)
if err != nil {
return nil, err
}

return &Server{pieceMgr: pieceMgr}, nil
func NewServer(pieceMgr *piecestorage.PieceStorageManager) *Server {
return &Server{pieceMgr: pieceMgr}
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 3 additions & 1 deletion retrievalprovider/httpretrieval/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/gorilla/mux"
"github.com/ipfs-force-community/droplet/v2/config"
"github.com/ipfs-force-community/droplet/v2/piecestorage"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -76,8 +77,9 @@ func TestRetrievalByPiece(t *testing.T) {
assert.NoError(t, err)
assert.NoError(t, f.Close())

s, err := NewServer(&cfg.PieceStorage)
pieceStorage, err := piecestorage.NewPieceStorageManager(&cfg.PieceStorage)
assert.NoError(t, err)
s := NewServer(pieceStorage)
port := "34897"
startHTTPServer(ctx, t, port, s)

Expand Down