From 0c8d6489980d2ae2d3630ab33e371c47739eb9a2 Mon Sep 17 00:00:00 2001 From: laser Date: Thu, 18 Jun 2020 13:36:48 -0700 Subject: [PATCH] specify which CID is being blacklisted (it's the piece) --- api/api_storage.go | 4 ++-- api/apistruct/struct.go | 12 ++++++------ cmd/lotus-storage-miner/market.go | 14 +++++++------- node/builder.go | 4 ++-- node/config/def.go | 4 ++-- node/impl/storminer.go | 14 +++++++------- node/modules/dtypes/miner.go | 4 ++-- node/modules/storageminer.go | 10 +++++----- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/api/api_storage.go b/api/api_storage.go index 0eda830dc..afc25f1c5 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -56,8 +56,8 @@ type StorageMiner interface { DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error) DealsSetAcceptingStorageDeals(context.Context, bool) error - DealsBlacklist(context.Context) ([]cid.Cid, error) - DealsSetBlacklist(context.Context, []cid.Cid) error + DealsPieceCidBlacklist(context.Context) ([]cid.Cid, error) + DealsSetPieceCidBlacklist(context.Context, []cid.Cid) error StorageAddLocal(ctx context.Context, path string) error } diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 43c0a423e..3d2375c87 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -226,8 +226,8 @@ type StorageMinerStruct struct { DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"` DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"` DealsSetAcceptingStorageDeals func(context.Context, bool) error `perm:"admin"` - DealsBlacklist func(context.Context) ([]cid.Cid, error) `perm:"admin"` - DealsSetBlacklist func(context.Context, []cid.Cid) error `perm:"read"` + DealsPieceCidBlacklist func(context.Context) ([]cid.Cid, error) `perm:"admin"` + DealsSetPieceCidBlacklist func(context.Context, []cid.Cid) error `perm:"read"` StorageAddLocal func(ctx context.Context, path string) error `perm:"admin"` } @@ -874,12 +874,12 @@ func (c *StorageMinerStruct) DealsSetAcceptingStorageDeals(ctx context.Context, return c.Internal.DealsSetAcceptingStorageDeals(ctx, b) } -func (c *StorageMinerStruct) DealsBlacklist(ctx context.Context) ([]cid.Cid, error) { - return c.Internal.DealsBlacklist(ctx) +func (c *StorageMinerStruct) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) { + return c.Internal.DealsPieceCidBlacklist(ctx) } -func (c *StorageMinerStruct) DealsSetBlacklist(ctx context.Context, cids []cid.Cid) error { - return c.Internal.DealsSetBlacklist(ctx, cids) +func (c *StorageMinerStruct) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error { + return c.Internal.DealsSetPieceCidBlacklist(ctx, cids) } func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error { diff --git a/cmd/lotus-storage-miner/market.go b/cmd/lotus-storage-miner/market.go index f12bce62c..1f7b84371 100644 --- a/cmd/lotus-storage-miner/market.go +++ b/cmd/lotus-storage-miner/market.go @@ -293,7 +293,7 @@ var dealsListCmd = &cli.Command{ var getBlacklistCmd = &cli.Command{ Name: "get-blacklist", - Usage: "List the CIDs in the storage miner's blacklist", + Usage: "List the contents of the storage miner's piece CID blacklist", Flags: []cli.Flag{ &CidBaseFlag, }, @@ -304,7 +304,7 @@ var getBlacklistCmd = &cli.Command{ } defer closer() - blacklist, err := api.DealsBlacklist(lcli.DaemonContext(cctx)) + blacklist, err := api.DealsPieceCidBlacklist(lcli.DaemonContext(cctx)) if err != nil { return err } @@ -324,8 +324,8 @@ var getBlacklistCmd = &cli.Command{ var setBlacklistCmd = &cli.Command{ Name: "set-blacklist", - Usage: "Set the storage miner's list of blacklisted CIDs", - ArgsUsage: "[ (optional, will read from stdin if omitted)]", + Usage: "Set the storage miner's list of blacklisted piece CIDs", + ArgsUsage: "[ (optional, will read from stdin if omitted)]", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { api, closer, err := lcli.GetStorageMinerAPI(cctx) @@ -365,13 +365,13 @@ var setBlacklistCmd = &cli.Command{ return err } - return api.DealsSetBlacklist(lcli.DaemonContext(cctx), blacklist) + return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), blacklist) }, } var resetBlacklistCmd = &cli.Command{ Name: "reset-blacklist", - Usage: "Remove all entries from the storage miner's blacklist", + Usage: "Remove all entries from the storage miner's piece CID blacklist", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { api, closer, err := lcli.GetStorageMinerAPI(cctx) @@ -380,6 +380,6 @@ var resetBlacklistCmd = &cli.Command{ } defer closer() - return api.DealsSetBlacklist(lcli.DaemonContext(cctx), []cid.Cid{}) + return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), []cid.Cid{}) }, } diff --git a/node/builder.go b/node/builder.go index 52e089bbe..bf32089e0 100644 --- a/node/builder.go +++ b/node/builder.go @@ -314,8 +314,8 @@ func Online() Option { Override(new(dtypes.AcceptingStorageDealsConfigFunc), modules.NewAcceptingStorageDealsConfigFunc), Override(new(dtypes.SetAcceptingStorageDealsConfigFunc), modules.NewSetAcceptingStorageDealsConfigFunc), - Override(new(dtypes.StorageDealCidBlacklistConfigFunc), modules.NewStorageDealCidBlacklistConfigFunc), - Override(new(dtypes.SetStorageDealCidBlacklistConfigFunc), modules.NewSetStorageDealCidBlacklistConfigFunc), + Override(new(dtypes.StorageDealPieceCidBlacklistConfigFunc), modules.NewStorageDealPieceCidBlacklistConfigFunc), + Override(new(dtypes.SetStorageDealPieceCidBlacklistConfigFunc), modules.NewSetStorageDealPieceCidBlacklistConfigFunc), ), ) } diff --git a/node/config/def.go b/node/config/def.go index b92ac3b4d..f9928ed3f 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -35,7 +35,7 @@ type StorageMiner struct { type DealmakingConfig struct { AcceptingStorageDeals bool - Blacklist []cid.Cid + PieceCidBlacklist []cid.Cid } // API contains configs for API endpoint @@ -124,7 +124,7 @@ func DefaultStorageMiner() *StorageMiner { Dealmaking: DealmakingConfig{ AcceptingStorageDeals: true, - Blacklist: []cid.Cid{}, + PieceCidBlacklist: []cid.Cid{}, }, } cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http" diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 2863a9d28..6eba12501 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -43,9 +43,9 @@ type StorageMinerAPI struct { StorageMgr *sectorstorage.Manager `optional:"true"` *stores.Index - SetAcceptingStorageDealsConfigFunc dtypes.SetAcceptingStorageDealsConfigFunc - StorageDealCidBlacklistConfigFunc dtypes.StorageDealCidBlacklistConfigFunc - SetStorageDealCidBlacklistConfigFunc dtypes.SetStorageDealCidBlacklistConfigFunc + SetAcceptingStorageDealsConfigFunc dtypes.SetAcceptingStorageDealsConfigFunc + StorageDealPieceCidBlacklistConfigFunc dtypes.StorageDealPieceCidBlacklistConfigFunc + SetStorageDealPieceCidBlacklistConfigFunc dtypes.SetStorageDealPieceCidBlacklistConfigFunc } func (sm *StorageMinerAPI) ServeRemote(w http.ResponseWriter, r *http.Request) { @@ -234,12 +234,12 @@ func (sm *StorageMinerAPI) DealsImportData(ctx context.Context, deal cid.Cid, fn return sm.StorageProvider.ImportDataForDeal(ctx, deal, fi) } -func (sm *StorageMinerAPI) DealsBlacklist(ctx context.Context) ([]cid.Cid, error) { - return sm.StorageDealCidBlacklistConfigFunc() +func (sm *StorageMinerAPI) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) { + return sm.StorageDealPieceCidBlacklistConfigFunc() } -func (sm *StorageMinerAPI) DealsSetBlacklist(ctx context.Context, cids []cid.Cid) error { - return sm.SetStorageDealCidBlacklistConfigFunc(cids) +func (sm *StorageMinerAPI) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error { + return sm.SetStorageDealPieceCidBlacklistConfigFunc(cids) } func (sm *StorageMinerAPI) StorageAddLocal(ctx context.Context, path string) error { diff --git a/node/modules/dtypes/miner.go b/node/modules/dtypes/miner.go index 04ae07a53..a9d278ca4 100644 --- a/node/modules/dtypes/miner.go +++ b/node/modules/dtypes/miner.go @@ -21,8 +21,8 @@ type SetAcceptingStorageDealsConfigFunc func(bool) error // StorageDealCidBlacklistConfigFunc is a function which reads from miner config // to obtain a list of CIDs for which the storage miner will not accept storage // proposals. -type StorageDealCidBlacklistConfigFunc func() ([]cid.Cid, error) +type StorageDealPieceCidBlacklistConfigFunc func() ([]cid.Cid, error) // SetStorageDealCidBlacklistConfigFunc is a function which is used to set a // list of CIDs for which the storage miner will reject deal proposals. -type SetStorageDealCidBlacklistConfigFunc func([]cid.Cid) error +type SetStorageDealPieceCidBlacklistConfigFunc func([]cid.Cid) error diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 49893c494..73e062c9c 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -309,7 +309,7 @@ func NewStorageAsk(ctx helpers.MetricsCtx, fapi lapi.FullNode, ds dtypes.Metadat return storedAsk, nil } -func StorageProvider(minerAddress dtypes.MinerAddress, ffiConfig *ffiwrapper.Config, storedAsk *storedask.StoredAsk, h host.Host, ds dtypes.MetadataDS, ibs dtypes.StagingBlockstore, r repo.LockedRepo, pieceStore dtypes.ProviderPieceStore, dataTransfer dtypes.ProviderDataTransfer, spn storagemarket.StorageProviderNode, isAcceptingFunc dtypes.AcceptingStorageDealsConfigFunc, blacklistFunc dtypes.StorageDealCidBlacklistConfigFunc) (storagemarket.StorageProvider, error) { +func StorageProvider(minerAddress dtypes.MinerAddress, ffiConfig *ffiwrapper.Config, storedAsk *storedask.StoredAsk, h host.Host, ds dtypes.MetadataDS, ibs dtypes.StagingBlockstore, r repo.LockedRepo, pieceStore dtypes.ProviderPieceStore, dataTransfer dtypes.ProviderDataTransfer, spn storagemarket.StorageProviderNode, isAcceptingFunc dtypes.AcceptingStorageDealsConfigFunc, blacklistFunc dtypes.StorageDealPieceCidBlacklistConfigFunc) (storagemarket.StorageProvider, error) { net := smnet.NewFromLibp2pHost(h) store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path())) if err != nil { @@ -411,19 +411,19 @@ func NewSetAcceptingStorageDealsConfigFunc(r repo.LockedRepo) (dtypes.SetAccepti }, nil } -func NewStorageDealCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealCidBlacklistConfigFunc, error) { +func NewStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealPieceCidBlacklistConfigFunc, error) { return func() (out []cid.Cid, err error) { err = readCfg(r, func(cfg *config.StorageMiner) { - out = cfg.Dealmaking.Blacklist + out = cfg.Dealmaking.PieceCidBlacklist }) return }, nil } -func NewSetStorageDealCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealCidBlacklistConfigFunc, error) { +func NewSetStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealPieceCidBlacklistConfigFunc, error) { return func(blacklist []cid.Cid) (err error) { err = mutateCfg(r, func(cfg *config.StorageMiner) { - cfg.Dealmaking.Blacklist = blacklist + cfg.Dealmaking.PieceCidBlacklist = blacklist }) return }, nil