get and set storage deal acceptance through CLI

This commit is contained in:
laser
2020-06-11 12:59:50 -07:00
parent 67110ce739
commit 7587e6c08b
8 changed files with 56 additions and 6 deletions
+4
View File
@@ -11,3 +11,7 @@ type MinerID abi.ActorID
// IsAcceptingStorageDealsFunc is a function which reads from miner config to
// determine if the user has disabled storage deals (or not).
type IsAcceptingStorageDealsFunc func() (bool, error)
// SetAcceptingStorageDealsFunc is a function which is used to disable or enable
// storage deal acceptance.
type SetAcceptingStorageDealsFunc func(bool) error
+20
View File
@@ -2,6 +2,7 @@ package modules
import (
"context"
"errors"
"net/http"
"github.com/ipfs/go-bitswap"
@@ -17,6 +18,7 @@ import (
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/routing"
"go.uber.org/fx"
"go.uber.org/multierr"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@@ -392,3 +394,21 @@ func NewIsAcceptingStorageDealsFunc(r repo.LockedRepo) (dtypes.IsAcceptingStorag
return cfg.Dealmaking.IsAcceptingStorageDeals, nil
}, nil
}
func NewSetAcceptingStorageDealsFunc(r repo.LockedRepo) (dtypes.SetAcceptingStorageDealsFunc, error) {
return func(b bool) error {
var typeErr error
setConfigErr := r.SetConfig(func(raw interface{}) {
cfg, ok := raw.(*config.StorageMiner)
if !ok {
typeErr = errors.New("expected storage miner config")
return
}
cfg.Dealmaking.IsAcceptingStorageDeals = b
})
return multierr.Combine(typeErr, setConfigErr)
}, nil
}