blacklist -> blocklist
This commit is contained in:
parent
99060fbb64
commit
de7d6c255c
@ -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
|
||||||
DealsPieceCidBlacklist(context.Context) ([]cid.Cid, error)
|
DealsPieceCidBlocklist(context.Context) ([]cid.Cid, error)
|
||||||
DealsSetPieceCidBlacklist(context.Context, []cid.Cid) error
|
DealsSetPieceCidBlocklist(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"`
|
||||||
DealsPieceCidBlacklist func(context.Context) ([]cid.Cid, error) `perm:"admin"`
|
DealsPieceCidBlocklist func(context.Context) ([]cid.Cid, error) `perm:"admin"`
|
||||||
DealsSetPieceCidBlacklist func(context.Context, []cid.Cid) error `perm:"read"`
|
DealsSetPieceCidBlocklist 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) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
func (c *StorageMinerStruct) DealsPieceCidBlocklist(ctx context.Context) ([]cid.Cid, error) {
|
||||||
return c.Internal.DealsPieceCidBlacklist(ctx)
|
return c.Internal.DealsPieceCidBlocklist(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error {
|
func (c *StorageMinerStruct) DealsSetPieceCidBlocklist(ctx context.Context, cids []cid.Cid) error {
|
||||||
return c.Internal.DealsSetPieceCidBlacklist(ctx, cids)
|
return c.Internal.DealsSetPieceCidBlocklist(ctx, cids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error {
|
func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
@ -227,9 +227,9 @@ var dealsCmd = &cli.Command{
|
|||||||
disableCmd,
|
disableCmd,
|
||||||
setAskCmd,
|
setAskCmd,
|
||||||
getAskCmd,
|
getAskCmd,
|
||||||
setBlacklistCmd,
|
setBlocklistCmd,
|
||||||
getBlacklistCmd,
|
getBlocklistCmd,
|
||||||
resetBlacklistCmd,
|
resetBlocklistCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,9 +289,9 @@ var dealsListCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var getBlacklistCmd = &cli.Command{
|
var getBlocklistCmd = &cli.Command{
|
||||||
Name: "get-blacklist",
|
Name: "get-blocklist",
|
||||||
Usage: "List the contents of the storage miner's piece CID blacklist",
|
Usage: "List the contents of the storage miner's piece CID blocklist",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&CidBaseFlag,
|
&CidBaseFlag,
|
||||||
},
|
},
|
||||||
@ -302,7 +302,7 @@ var getBlacklistCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
blacklist, err := api.DealsPieceCidBlacklist(lcli.DaemonContext(cctx))
|
blocklist, err := api.DealsPieceCidBlocklist(lcli.DaemonContext(cctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -312,17 +312,17 @@ var getBlacklistCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx := range blacklist {
|
for idx := range blocklist {
|
||||||
fmt.Println(encoder.Encode(blacklist[idx]))
|
fmt.Println(encoder.Encode(blocklist[idx]))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var setBlacklistCmd = &cli.Command{
|
var setBlocklistCmd = &cli.Command{
|
||||||
Name: "set-blacklist",
|
Name: "set-blocklist",
|
||||||
Usage: "Set the storage miner's list of blacklisted piece CIDs",
|
Usage: "Set the storage miner's list of blocklisted piece CIDs",
|
||||||
ArgsUsage: "[<path-of-file-containing-newline-delimited-piece-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 {
|
||||||
@ -348,14 +348,14 @@ var setBlacklistCmd = &cli.Command{
|
|||||||
scanner = bufio.NewScanner(file)
|
scanner = bufio.NewScanner(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
var blacklist []cid.Cid
|
var blocklist []cid.Cid
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
decoded, err := cid.Decode(scanner.Text())
|
decoded, err := cid.Decode(scanner.Text())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklist = append(blacklist, decoded)
|
blocklist = append(blocklist, decoded)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = scanner.Err()
|
err = scanner.Err()
|
||||||
@ -363,13 +363,13 @@ var setBlacklistCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), blacklist)
|
return api.DealsSetPieceCidBlocklist(lcli.DaemonContext(cctx), blocklist)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var resetBlacklistCmd = &cli.Command{
|
var resetBlocklistCmd = &cli.Command{
|
||||||
Name: "reset-blacklist",
|
Name: "reset-blocklist",
|
||||||
Usage: "Remove all entries from the storage miner's piece CID blacklist",
|
Usage: "Remove all entries from the storage miner's piece CID blocklist",
|
||||||
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)
|
||||||
@ -378,6 +378,6 @@ var resetBlacklistCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
return api.DealsSetPieceCidBlacklist(lcli.DaemonContext(cctx), []cid.Cid{})
|
return api.DealsSetPieceCidBlocklist(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.StorageDealPieceCidBlacklistConfigFunc), modules.NewStorageDealPieceCidBlacklistConfigFunc),
|
Override(new(dtypes.StorageDealPieceCidBlocklistConfigFunc), modules.NewStorageDealPieceCidBlocklistConfigFunc),
|
||||||
Override(new(dtypes.SetStorageDealPieceCidBlacklistConfigFunc), modules.NewSetStorageDealPieceCidBlacklistConfigFunc),
|
Override(new(dtypes.SetStorageDealPieceCidBlocklistConfigFunc), modules.NewSetStorageDealPieceCidBlocklistConfigFunc),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ type StorageMiner struct {
|
|||||||
|
|
||||||
type DealmakingConfig struct {
|
type DealmakingConfig struct {
|
||||||
AcceptingStorageDeals bool
|
AcceptingStorageDeals bool
|
||||||
PieceCidBlacklist []cid.Cid
|
PieceCidBlocklist []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,
|
||||||
PieceCidBlacklist: []cid.Cid{},
|
PieceCidBlocklist: []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
|
||||||
StorageDealPieceCidBlacklistConfigFunc dtypes.StorageDealPieceCidBlacklistConfigFunc
|
StorageDealPieceCidBlocklistConfigFunc dtypes.StorageDealPieceCidBlocklistConfigFunc
|
||||||
SetStorageDealPieceCidBlacklistConfigFunc dtypes.SetStorageDealPieceCidBlacklistConfigFunc
|
SetStorageDealPieceCidBlocklistConfigFunc dtypes.SetStorageDealPieceCidBlocklistConfigFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
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) DealsPieceCidBlacklist(ctx context.Context) ([]cid.Cid, error) {
|
func (sm *StorageMinerAPI) DealsPieceCidBlocklist(ctx context.Context) ([]cid.Cid, error) {
|
||||||
return sm.StorageDealPieceCidBlacklistConfigFunc()
|
return sm.StorageDealPieceCidBlocklistConfigFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) DealsSetPieceCidBlacklist(ctx context.Context, cids []cid.Cid) error {
|
func (sm *StorageMinerAPI) DealsSetPieceCidBlocklist(ctx context.Context, cids []cid.Cid) error {
|
||||||
return sm.SetStorageDealPieceCidBlacklistConfigFunc(cids)
|
return sm.SetStorageDealPieceCidBlocklistConfigFunc(cids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) StorageAddLocal(ctx context.Context, path string) error {
|
func (sm *StorageMinerAPI) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
@ -18,11 +18,11 @@ type AcceptingStorageDealsConfigFunc func() (bool, error)
|
|||||||
// storage deal acceptance.
|
// storage deal acceptance.
|
||||||
type SetAcceptingStorageDealsConfigFunc func(bool) error
|
type SetAcceptingStorageDealsConfigFunc func(bool) error
|
||||||
|
|
||||||
// StorageDealCidBlacklistConfigFunc is a function which reads from miner config
|
// StorageDealCidBlocklistConfigFunc 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 StorageDealPieceCidBlacklistConfigFunc func() ([]cid.Cid, error)
|
type StorageDealPieceCidBlocklistConfigFunc func() ([]cid.Cid, error)
|
||||||
|
|
||||||
// SetStorageDealCidBlacklistConfigFunc is a function which is used to set a
|
// SetStorageDealCidBlocklistConfigFunc 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 SetStorageDealPieceCidBlacklistConfigFunc func([]cid.Cid) error
|
type SetStorageDealPieceCidBlocklistConfigFunc 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.StorageDealPieceCidBlacklistConfigFunc) (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, blocklistFunc dtypes.StorageDealPieceCidBlocklistConfigFunc) (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 {
|
||||||
@ -327,15 +327,15 @@ func StorageProvider(minerAddress dtypes.MinerAddress, ffiConfig *ffiwrapper.Con
|
|||||||
return false, "miner is not accepting storage deals", nil
|
return false, "miner is not accepting storage deals", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklist, err := blacklistFunc()
|
blocklist, err := blocklistFunc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "miner error", err
|
return false, "miner error", err
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx := range blacklist {
|
for idx := range blocklist {
|
||||||
if deal.Proposal.PieceCID.Equals(blacklist[idx]) {
|
if deal.Proposal.PieceCID.Equals(blocklist[idx]) {
|
||||||
log.Warnf("piece CID in proposal %s is blacklisted; rejecting storage deal proposal from client: %s", deal.Proposal.PieceCID, deal.Client.String())
|
log.Warnf("piece CID in proposal %s is blocklisted; rejecting storage deal proposal from client: %s", deal.Proposal.PieceCID, deal.Client.String())
|
||||||
return false, fmt.Sprintf("miner has blacklisted piece CID %s", deal.Proposal.PieceCID), nil
|
return false, fmt.Sprintf("miner has blocklisted piece CID %s", deal.Proposal.PieceCID), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,19 +411,19 @@ func NewSetAcceptingStorageDealsConfigFunc(r repo.LockedRepo) (dtypes.SetAccepti
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealPieceCidBlacklistConfigFunc, error) {
|
func NewStorageDealPieceCidBlocklistConfigFunc(r repo.LockedRepo) (dtypes.StorageDealPieceCidBlocklistConfigFunc, 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.PieceCidBlacklist
|
out = cfg.Dealmaking.PieceCidBlocklist
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSetStorageDealPieceCidBlacklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealPieceCidBlacklistConfigFunc, error) {
|
func NewSetStorageDealPieceCidBlocklistConfigFunc(r repo.LockedRepo) (dtypes.SetStorageDealPieceCidBlocklistConfigFunc, error) {
|
||||||
return func(blacklist []cid.Cid) (err error) {
|
return func(blocklist []cid.Cid) (err error) {
|
||||||
err = mutateCfg(r, func(cfg *config.StorageMiner) {
|
err = mutateCfg(r, func(cfg *config.StorageMiner) {
|
||||||
cfg.Dealmaking.PieceCidBlacklist = blacklist
|
cfg.Dealmaking.PieceCidBlocklist = blocklist
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user