specify which CID is being blacklisted (it's the piece)
This commit is contained in:
parent
aa18d1985e
commit
0c8d648998
@ -56,8 +56,8 @@ type StorageMiner interface {
|
|||||||
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
||||||
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
||||||
DealsSetAcceptingStorageDeals(context.Context, bool) error
|
DealsSetAcceptingStorageDeals(context.Context, bool) error
|
||||||
DealsBlacklist(context.Context) ([]cid.Cid, error)
|
DealsPieceCidBlacklist(context.Context) ([]cid.Cid, error)
|
||||||
DealsSetBlacklist(context.Context, []cid.Cid) error
|
DealsSetPieceCidBlacklist(context.Context, []cid.Cid) error
|
||||||
|
|
||||||
StorageAddLocal(ctx context.Context, path string) error
|
StorageAddLocal(ctx context.Context, path string) error
|
||||||
}
|
}
|
||||||
|
@ -226,8 +226,8 @@ type StorageMinerStruct struct {
|
|||||||
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
||||||
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
||||||
DealsSetAcceptingStorageDeals func(context.Context, bool) error `perm:"admin"`
|
DealsSetAcceptingStorageDeals func(context.Context, bool) error `perm:"admin"`
|
||||||
DealsBlacklist func(context.Context) ([]cid.Cid, error) `perm:"admin"`
|
DealsPieceCidBlacklist func(context.Context) ([]cid.Cid, error) `perm:"admin"`
|
||||||
DealsSetBlacklist func(context.Context, []cid.Cid) error `perm:"read"`
|
DealsSetPieceCidBlacklist func(context.Context, []cid.Cid) error `perm:"read"`
|
||||||
|
|
||||||
StorageAddLocal func(ctx context.Context, path string) error `perm:"admin"`
|
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)
|
return c.Internal.DealsSetAcceptingStorageDeals(ctx, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) DealsBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
func (c *StorageMinerStruct) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
||||||
return c.Internal.DealsBlacklist(ctx)
|
return c.Internal.DealsPieceCidBlacklist(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) DealsSetBlacklist(ctx context.Context, cids []cid.Cid) error {
|
func (c *StorageMinerStruct) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error {
|
||||||
return c.Internal.DealsSetBlacklist(ctx, cids)
|
return c.Internal.DealsSetPieceCidBlacklist(ctx, cids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error {
|
func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
@ -293,7 +293,7 @@ var dealsListCmd = &cli.Command{
|
|||||||
|
|
||||||
var getBlacklistCmd = &cli.Command{
|
var getBlacklistCmd = &cli.Command{
|
||||||
Name: "get-blacklist",
|
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{
|
Flags: []cli.Flag{
|
||||||
&CidBaseFlag,
|
&CidBaseFlag,
|
||||||
},
|
},
|
||||||
@ -304,7 +304,7 @@ var getBlacklistCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
blacklist, err := api.DealsBlacklist(lcli.DaemonContext(cctx))
|
blacklist, err := api.DealsPieceCidBlacklist(lcli.DaemonContext(cctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -324,8 +324,8 @@ var getBlacklistCmd = &cli.Command{
|
|||||||
|
|
||||||
var setBlacklistCmd = &cli.Command{
|
var setBlacklistCmd = &cli.Command{
|
||||||
Name: "set-blacklist",
|
Name: "set-blacklist",
|
||||||
Usage: "Set the storage miner's list of blacklisted CIDs",
|
Usage: "Set the storage miner's list of blacklisted piece CIDs",
|
||||||
ArgsUsage: "[<path-of-file-containing-newline-delimited-CIDs> (optional, will read from stdin if omitted)]",
|
ArgsUsage: "[<path-of-file-containing-newline-delimited-piece-CIDs> (optional, will read from stdin if omitted)]",
|
||||||
Flags: []cli.Flag{},
|
Flags: []cli.Flag{},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
@ -365,13 +365,13 @@ var setBlacklistCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.DealsSetBlacklist(lcli.DaemonContext(cctx), blacklist)
|
return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), blacklist)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var resetBlacklistCmd = &cli.Command{
|
var resetBlacklistCmd = &cli.Command{
|
||||||
Name: "reset-blacklist",
|
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{},
|
Flags: []cli.Flag{},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
@ -380,6 +380,6 @@ var resetBlacklistCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
return api.DealsSetBlacklist(lcli.DaemonContext(cctx), []cid.Cid{})
|
return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), []cid.Cid{})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -314,8 +314,8 @@ func Online() Option {
|
|||||||
|
|
||||||
Override(new(dtypes.AcceptingStorageDealsConfigFunc), modules.NewAcceptingStorageDealsConfigFunc),
|
Override(new(dtypes.AcceptingStorageDealsConfigFunc), modules.NewAcceptingStorageDealsConfigFunc),
|
||||||
Override(new(dtypes.SetAcceptingStorageDealsConfigFunc), modules.NewSetAcceptingStorageDealsConfigFunc),
|
Override(new(dtypes.SetAcceptingStorageDealsConfigFunc), modules.NewSetAcceptingStorageDealsConfigFunc),
|
||||||
Override(new(dtypes.StorageDealCidBlacklistConfigFunc), modules.NewStorageDealCidBlacklistConfigFunc),
|
Override(new(dtypes.StorageDealPieceCidBlacklistConfigFunc), modules.NewStorageDealPieceCidBlacklistConfigFunc),
|
||||||
Override(new(dtypes.SetStorageDealCidBlacklistConfigFunc), modules.NewSetStorageDealCidBlacklistConfigFunc),
|
Override(new(dtypes.SetStorageDealPieceCidBlacklistConfigFunc), modules.NewSetStorageDealPieceCidBlacklistConfigFunc),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ type StorageMiner struct {
|
|||||||
|
|
||||||
type DealmakingConfig struct {
|
type DealmakingConfig struct {
|
||||||
AcceptingStorageDeals bool
|
AcceptingStorageDeals bool
|
||||||
Blacklist []cid.Cid
|
PieceCidBlacklist []cid.Cid
|
||||||
}
|
}
|
||||||
|
|
||||||
// API contains configs for API endpoint
|
// API contains configs for API endpoint
|
||||||
@ -124,7 +124,7 @@ func DefaultStorageMiner() *StorageMiner {
|
|||||||
|
|
||||||
Dealmaking: DealmakingConfig{
|
Dealmaking: DealmakingConfig{
|
||||||
AcceptingStorageDeals: true,
|
AcceptingStorageDeals: true,
|
||||||
Blacklist: []cid.Cid{},
|
PieceCidBlacklist: []cid.Cid{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
|
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
|
||||||
|
@ -44,8 +44,8 @@ type StorageMinerAPI struct {
|
|||||||
*stores.Index
|
*stores.Index
|
||||||
|
|
||||||
SetAcceptingStorageDealsConfigFunc dtypes.SetAcceptingStorageDealsConfigFunc
|
SetAcceptingStorageDealsConfigFunc dtypes.SetAcceptingStorageDealsConfigFunc
|
||||||
StorageDealCidBlacklistConfigFunc dtypes.StorageDealCidBlacklistConfigFunc
|
StorageDealPieceCidBlacklistConfigFunc dtypes.StorageDealPieceCidBlacklistConfigFunc
|
||||||
SetStorageDealCidBlacklistConfigFunc dtypes.SetStorageDealCidBlacklistConfigFunc
|
SetStorageDealPieceCidBlacklistConfigFunc dtypes.SetStorageDealPieceCidBlacklistConfigFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) ServeRemote(w http.ResponseWriter, r *http.Request) {
|
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)
|
return sm.StorageProvider.ImportDataForDeal(ctx, deal, fi)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) DealsBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
func (sm *StorageMinerAPI) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
||||||
return sm.StorageDealCidBlacklistConfigFunc()
|
return sm.StorageDealPieceCidBlacklistConfigFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) DealsSetBlacklist(ctx context.Context, cids []cid.Cid) error {
|
func (sm *StorageMinerAPI) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error {
|
||||||
return sm.SetStorageDealCidBlacklistConfigFunc(cids)
|
return sm.SetStorageDealPieceCidBlacklistConfigFunc(cids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) StorageAddLocal(ctx context.Context, path string) error {
|
func (sm *StorageMinerAPI) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
@ -21,8 +21,8 @@ type SetAcceptingStorageDealsConfigFunc func(bool) error
|
|||||||
// StorageDealCidBlacklistConfigFunc is a function which reads from miner config
|
// StorageDealCidBlacklistConfigFunc is a function which reads from miner config
|
||||||
// to obtain a list of CIDs for which the storage miner will not accept storage
|
// to obtain a list of CIDs for which the storage miner will not accept storage
|
||||||
// proposals.
|
// proposals.
|
||||||
type StorageDealCidBlacklistConfigFunc func() ([]cid.Cid, error)
|
type StorageDealPieceCidBlacklistConfigFunc func() ([]cid.Cid, error)
|
||||||
|
|
||||||
// SetStorageDealCidBlacklistConfigFunc is a function which is used to set a
|
// SetStorageDealCidBlacklistConfigFunc is a function which is used to set a
|
||||||
// list of CIDs for which the storage miner will reject deal proposals.
|
// list of CIDs for which the storage miner will reject deal proposals.
|
||||||
type SetStorageDealCidBlacklistConfigFunc func([]cid.Cid) error
|
type SetStorageDealPieceCidBlacklistConfigFunc func([]cid.Cid) error
|
||||||
|
@ -309,7 +309,7 @@ func NewStorageAsk(ctx helpers.MetricsCtx, fapi lapi.FullNode, ds dtypes.Metadat
|
|||||||
return storedAsk, nil
|
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)
|
net := smnet.NewFromLibp2pHost(h)
|
||||||
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
|
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -411,19 +411,19 @@ func NewSetAcceptingStorageDealsConfigFunc(r repo.LockedRepo) (dtypes.SetAccepti
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageDealCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealCidBlacklistConfigFunc, error) {
|
func NewStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealPieceCidBlacklistConfigFunc, error) {
|
||||||
return func() (out []cid.Cid, err error) {
|
return func() (out []cid.Cid, err error) {
|
||||||
err = readCfg(r, func(cfg *config.StorageMiner) {
|
err = readCfg(r, func(cfg *config.StorageMiner) {
|
||||||
out = cfg.Dealmaking.Blacklist
|
out = cfg.Dealmaking.PieceCidBlacklist
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSetStorageDealCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealCidBlacklistConfigFunc, error) {
|
func NewSetStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealPieceCidBlacklistConfigFunc, error) {
|
||||||
return func(blacklist []cid.Cid) (err error) {
|
return func(blacklist []cid.Cid) (err error) {
|
||||||
err = mutateCfg(r, func(cfg *config.StorageMiner) {
|
err = mutateCfg(r, func(cfg *config.StorageMiner) {
|
||||||
cfg.Dealmaking.Blacklist = blacklist
|
cfg.Dealmaking.PieceCidBlacklist = blacklist
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user