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/refrator package #32

Merged
merged 1 commit into from
Nov 15, 2021
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
7 changes: 3 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/filecoin-project/venus-market/client"
"github.com/filecoin-project/venus-market/imports"
"github.com/filecoin-project/venus-market/piece"
"github.com/filecoin-project/venus-market/types"
"github.com/filecoin-project/venus-market/utils"
)
Expand Down Expand Up @@ -142,9 +141,9 @@ type MarketFullNode interface {
MarkDealsAsPacking(ctx context.Context, miner address.Address, deals []abi.DealID) error //perm:write
UpdateDealOnPacking(ctx context.Context, miner address.Address, dealID abi.DealID, sectorid abi.SectorNumber, offset abi.PaddedPieceSize) error //perm:write
UpdateDealStatus(ctx context.Context, miner address.Address, dealID abi.DealID, pieceStatus string) error //perm:write
GetDeals(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*piece.DealInfo, error) //perm:read
GetUnPackedDeals(ctx context.Context, miner address.Address, spec *piece.GetDealSpec) ([]*piece.DealInfoIncludePath, error) //perm:read
AssignUnPackedDeals(ctx context.Context, miner address.Address, ssize abi.SectorSize, spec *piece.GetDealSpec) ([]*piece.DealInfoIncludePath, error) //perm:write
GetDeals(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*types.DealInfo, error) //perm:read
GetUnPackedDeals(ctx context.Context, miner address.Address, spec *types.GetDealSpec) ([]*types.DealInfoIncludePath, error) //perm:read
AssignUnPackedDeals(ctx context.Context, miner address.Address, ssize abi.SectorSize, spec *types.GetDealSpec) ([]*types.DealInfoIncludePath, error) //perm:write

//market event
ResponseMarketEvent(ctx context.Context, resp *types2.ResponseEvent) error //perm:read
Expand Down
26 changes: 13 additions & 13 deletions api/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/paych"

"github.com/filecoin-project/venus-market/minermgr"
"github.com/filecoin-project/venus-market/retrievaladapter"
"github.com/filecoin-project/venus-market/retrievalprovider"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
Expand All @@ -33,8 +33,8 @@ import (
clients2 "github.com/filecoin-project/venus-market/api/clients"
"github.com/filecoin-project/venus-market/config"
"github.com/filecoin-project/venus-market/network"
"github.com/filecoin-project/venus-market/piece"
storageadapter2 "github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/piecestorage"
storageadapter2 "github.com/filecoin-project/venus-market/storageprovider"
"github.com/filecoin-project/venus-market/types"

mTypes "github.com/filecoin-project/venus-messager/types"
Expand All @@ -57,15 +57,15 @@ type MarketNodeImpl struct {
FullNode apiface.FullNode
Host host.Host
StorageProvider storageadapter2.StorageProviderV2
RetrievalProvider retrievaladapter.IRetrievalProvider
RetrievalAskHandler retrievaladapter.IAskHandler
RetrievalProvider retrievalprovider.IRetrievalProvider
RetrievalAskHandler retrievalprovider.IAskHandler
DataTransfer network.ProviderDataTransfer
DealPublisher *storageadapter2.DealPublisher
DealAssigner piece.DealAssiger
DealAssigner storageadapter2.DealAssiger

Messager clients2.IMessager `optional:"true"`
DAGStore *dagstore.DAGStore
PieceStorage piece.IPieceStorage
PieceStorage piecestorage.IPieceStorage
MinerMgr minermgr.IMinerMgr
PaychAPI paych3.PaychAPI
Repo repo.Repo
Expand Down Expand Up @@ -243,19 +243,19 @@ func (m MarketNodeImpl) MarketPublishPendingDeals(ctx context.Context) error {
}

func (m MarketNodeImpl) PiecesListPieces(ctx context.Context) ([]cid.Cid, error) {
return m.DealAssigner.ListPieceInfoKeys()
return m.Repo.StorageDealRepo().ListPieceInfoKeys()
}

func (m MarketNodeImpl) PiecesListCidInfos(ctx context.Context) ([]cid.Cid, error) {
return m.Repo.CidInfoRepo().ListCidInfoKeys()
}

func (m MarketNodeImpl) PiecesGetPieceInfo(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error) {
pi, err := m.DealAssigner.GetPieceInfo(pieceCid)
pi, err := m.Repo.StorageDealRepo().GetPieceInfo(pieceCid)
if err != nil {
return nil, err
}
return &pi, nil
return pi, nil
}

func (m MarketNodeImpl) PiecesGetCIDInfo(ctx context.Context, payloadCid cid.Cid) (*piecestore.CIDInfo, error) {
Expand Down Expand Up @@ -631,11 +631,11 @@ func (m MarketNodeImpl) DagstoreGC(ctx context.Context) ([]types.DagstoreShardRe
return ret, nil
}

func (m MarketNodeImpl) GetUnPackedDeals(ctx context.Context, miner address.Address, spec *piece.GetDealSpec) ([]*piece.DealInfoIncludePath, error) {
func (m MarketNodeImpl) GetUnPackedDeals(ctx context.Context, miner address.Address, spec *types.GetDealSpec) ([]*types.DealInfoIncludePath, error) {
return m.DealAssigner.GetUnPackedDeals(ctx, miner, spec)
}

func (m MarketNodeImpl) AssignUnPackedDeals(ctx context.Context, miner address.Address, ssize abi.SectorSize, spec *piece.GetDealSpec) ([]*piece.DealInfoIncludePath, error) {
func (m MarketNodeImpl) AssignUnPackedDeals(ctx context.Context, miner address.Address, ssize abi.SectorSize, spec *types.GetDealSpec) ([]*types.DealInfoIncludePath, error) {
return m.DealAssigner.AssignUnPackedDeals(ctx, miner, ssize, spec)
}

Expand All @@ -661,7 +661,7 @@ func (m MarketNodeImpl) DealsImportData(ctx context.Context, dealPropCid cid.Cid
return m.StorageProvider.ImportDataForDeal(ctx, dealPropCid, fi)
}

func (m MarketNodeImpl) GetDeals(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*piece.DealInfo, error) {
func (m MarketNodeImpl) GetDeals(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*types.DealInfo, error) {
return m.DealAssigner.GetDeals(ctx, miner, pageIndex, pageSize)
}

Expand Down
25 changes: 12 additions & 13 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import (

"github.com/filecoin-project/venus-market/config"
"github.com/filecoin-project/venus-market/imports"
"github.com/filecoin-project/venus-market/retrievaladapter"
"github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/retrievalprovider"
"github.com/filecoin-project/venus-market/storageprovider"
types2 "github.com/filecoin-project/venus-market/types"

marketNetwork "github.com/filecoin-project/venus-market/network"
Expand Down Expand Up @@ -840,8 +840,8 @@ func (a *API) clientRetrieve(ctx context.Context, order RetrievalOrder, ref *Fil
// the CARv1 (with ExtractV1File) or UnixFS export from it.

// this indicates we're proxying to IPFS.
proxyBss, retrieveIntoIPFS := a.RtvlBlockstoreAccessor.(*retrievaladapter.ProxyBlockstoreAccessor)
carBss, retrieveIntoCAR := a.RtvlBlockstoreAccessor.(*retrievaladapter.CARBlockstoreAccessor)
proxyBss, retrieveIntoIPFS := a.RtvlBlockstoreAccessor.(*retrievalprovider.ProxyBlockstoreAccessor)
carBss, retrieveIntoCAR := a.RtvlBlockstoreAccessor.(*retrievalprovider.CARBlockstoreAccessor)

carPath := order.FromLocalCAR
if carPath == "" {
Expand Down Expand Up @@ -1296,7 +1296,7 @@ func (a *API) ClientGetDealStatus(ctx context.Context, statusCode uint64) (strin
// must be called when done.
func (a *API) dealBlockstore(root cid.Cid) (bstore.Blockstore, func(), error) {
switch acc := a.StorageBlockstoreAccessor.(type) {
case *storageadapter.ImportsBlockstoreAccessor:
case *storageprovider.ImportsBlockstoreAccessor:
bs, err := acc.Get(root)
if err != nil {
return nil, nil, xerrors.Errorf("no import found for root %s: %w", root, err)
Expand All @@ -1307,7 +1307,7 @@ func (a *API) dealBlockstore(root cid.Cid) (bstore.Blockstore, func(), error) {
}
return bs, doneFn, nil

case *storageadapter.ProxyBlockstoreAccessor:
case *storageprovider.ProxyBlockstoreAccessor:
return acc.Blockstore, func() {}, nil

default:
Expand Down
4 changes: 2 additions & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/filecoin-project/venus-market/imports"
"github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/storageprovider"
)

//go:embed testdata/*
Expand All @@ -37,7 +37,7 @@ func TestImportLocal(t *testing.T) {

a := &API{
Imports: im,
StorageBlockstoreAccessor: storageadapter.NewImportsBlockstoreAccessor(im),
StorageBlockstoreAccessor: storageprovider.NewImportsBlockstoreAccessor(im),
}

b, err := testdata.ReadFile("testdata/payload.txt")
Expand Down
10 changes: 5 additions & 5 deletions client/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/filecoin-project/venus-market/journal"
"github.com/filecoin-project/venus-market/network"
"github.com/filecoin-project/venus-market/paychmgr"
"github.com/filecoin-project/venus-market/retrievaladapter"
"github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/retrievalprovider"
"github.com/filecoin-project/venus-market/storageprovider"
marketevents "github.com/filecoin-project/venus-market/utils"

"github.com/filecoin-project/venus/app/client/apiface"
Expand Down Expand Up @@ -123,7 +123,7 @@ func NewClientGraphsyncDataTransfer(lc fx.Lifecycle, h host.Host, gs network.Gra
// StorageBlockstoreAccessor returns the default storage blockstore accessor
// from the import manager.
func StorageBlockstoreAccessor(importmgr ClientImportMgr) storagemarket.BlockstoreAccessor {
return storageadapter.NewImportsBlockstoreAccessor(importmgr)
return storageprovider.NewImportsBlockstoreAccessor(importmgr)
}

// RetrievalBlockstoreAccessor returns the default retrieval blockstore accessor
Expand All @@ -133,7 +133,7 @@ func RetrievalBlockstoreAccessor(r *config.HomeDir) (retrievalmarket.BlockstoreA
if err := os.MkdirAll(dir, 0755); err != nil {
return nil, xerrors.Errorf("failed to create directory %s: %w", dir, err)
}
return retrievaladapter.NewCARBlockstoreAccessor(dir), nil
return retrievalprovider.NewCARBlockstoreAccessor(dir), nil
}

func StorageClient(lc fx.Lifecycle, h host.Host, dataTransfer network.ClientDataTransfer, discovery *discoveryimpl.Local,
Expand Down Expand Up @@ -168,7 +168,7 @@ func StorageClient(lc fx.Lifecycle, h host.Host, dataTransfer network.ClientData
func RetrievalClient(lc fx.Lifecycle, h host.Host, dt network.ClientDataTransfer, payAPI *paychmgr.PaychAPI, resolver discovery.PeerResolver,
ds badger.RetrievalClientDS, fullApi apiface.FullNode, accessor retrievalmarket.BlockstoreAccessor, j journal.Journal) (retrievalmarket.RetrievalClient, error) {

adapter := retrievaladapter.NewRetrievalClientNode(payAPI, fullApi)
adapter := retrievalprovider.NewRetrievalClientNode(payAPI, fullApi)
libP2pHost := rmnet.NewFromLibp2pHost(h)
client, err := retrievalimpl.NewClient(libP2pHost, dt, adapter, resolver, ds, accessor)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/market-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/filecoin-project/venus-market/network"
"github.com/filecoin-project/venus-market/paychmgr"
"github.com/filecoin-project/venus-market/rpc"
"github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/storageprovider"
"github.com/filecoin-project/venus-market/types"
"github.com/filecoin-project/venus-market/utils"
"github.com/filecoin-project/venus/pkg/constants"
Expand Down Expand Up @@ -163,7 +163,7 @@ func marketClient(cctx *cli.Context) error {
network.NetworkOpts(false, cfg.SimultaneousTransfers),
paychmgr.PaychOpts,
fundmgr.FundMgrOpts,
storageadapter.StorageClientOpts,
storageprovider.StorageClientOpts,
client.MarketClientOpts,
func(s *builder.Settings) error {
s.Invokes[ExtractApiKey] = builder.InvokeOption{
Expand Down
12 changes: 6 additions & 6 deletions cmd/venus-market/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"github.com/filecoin-project/venus-market/metrics"
"github.com/filecoin-project/venus-market/network"
"github.com/filecoin-project/venus-market/paychmgr"
"github.com/filecoin-project/venus-market/piece"
"github.com/filecoin-project/venus-market/retrievaladapter"
"github.com/filecoin-project/venus-market/piecestorage"
"github.com/filecoin-project/venus-market/retrievalprovider"
"github.com/filecoin-project/venus-market/rpc"
"github.com/filecoin-project/venus-market/storageadapter"
"github.com/filecoin-project/venus-market/storageprovider"
"github.com/filecoin-project/venus-market/types"
"github.com/filecoin-project/venus-market/utils"
"github.com/filecoin-project/venus/pkg/constants"
Expand Down Expand Up @@ -190,13 +190,13 @@ func daemon(cctx *cli.Context) error {
clients.ClientsOpts(true, &cfg.Messager, &cfg.Signer, &cfg.Mysql),
models.DBOptions(true, &cfg.Mysql),
network.NetworkOpts(true, cfg.SimultaneousTransfers),
piece.PieceOpts(cfg),
piecestorage.PieceStorageOpts(cfg),
fundmgr.FundMgrOpts,
dagstore.DagstoreOpts,
paychmgr.PaychOpts,
// Markets
storageadapter.StorageProviderOpts(cfg),
retrievaladapter.RetrievalProviderOpts(cfg),
storageprovider.StorageProviderOpts(cfg),
retrievalprovider.RetrievalProviderOpts(cfg),

func(s *builder.Settings) error {
s.Invokes[ExtractApiKey] = builder.InvokeOption{
Expand Down
6 changes: 3 additions & 3 deletions dagstore/market_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dagstore
import (
"context"
"github.com/filecoin-project/venus-market/models/repo"
"github.com/filecoin-project/venus-market/piece"
"github.com/filecoin-project/venus-market/piecestorage"
"io"

"github.com/filecoin-project/dagstore/throttle"
Expand All @@ -19,14 +19,14 @@ type MarketAPI interface {
}

type marketAPI struct {
pieceStorage piece.IPieceStorage
pieceStorage piecestorage.IPieceStorage
pieceRepo repo.StorageDealRepo
throttle throttle.Throttler
}

var _ MarketAPI = (*marketAPI)(nil)

func NewMinerAPI(repo repo.Repo, pieceStorage piece.IPieceStorage, concurrency int) MarketAPI {
func NewMinerAPI(repo repo.Repo, pieceStorage piecestorage.IPieceStorage, concurrency int) MarketAPI {
return &marketAPI{
pieceRepo: repo.StorageDealRepo(),
pieceStorage: pieceStorage,
Expand Down
4 changes: 2 additions & 2 deletions dagstore/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/venus-market/builder"
"github.com/filecoin-project/venus-market/config"
"github.com/filecoin-project/venus-market/models/repo"
"github.com/filecoin-project/venus-market/piece"
"github.com/filecoin-project/venus-market/piecestorage"
xerrors "github.com/pkg/errors"
"go.uber.org/fx"
"os"
Expand All @@ -25,7 +25,7 @@ const (
)

// NewMinerAPI creates a new MarketAPI adaptor for the dagstore mounts.
func NewMarketAPI(lc fx.Lifecycle, r *config.DAGStoreConfig, repo repo.Repo, pieceStorage piece.IPieceStorage) (MarketAPI, error) {
func NewMarketAPI(lc fx.Lifecycle, r *config.DAGStoreConfig, repo repo.Repo, pieceStorage piecestorage.IPieceStorage) (MarketAPI, error) {
mountApi := NewMinerAPI(repo, pieceStorage, r.MaxConcurrencyStorageCalls)
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
Expand Down
17 changes: 0 additions & 17 deletions piece/modules.go

This file was deleted.

2 changes: 1 addition & 1 deletion piece/filestore.go → piecestorage/filestore.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package piece
package piecestorage

import (
"context"
Expand Down
Loading