unexport repo types; use a global var for every repo type
This commit is contained in:
parent
e3edab66e3
commit
f1f878a000
@ -121,7 +121,7 @@ func NewGeneratorWithSectorsAndUpgradeSchedule(numSectors int, us stmgr.UpgradeS
|
||||
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
||||
|
||||
mr := repo.NewMemory(nil)
|
||||
lr, err := mr.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := mr.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("taking mem-repo lock failed: %w", err)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func BenchmarkGetRandomness(b *testing.B) {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ var AuthApiInfoToken = &cli.Command{
|
||||
ti, ok := cctx.App.Metadata["repoType"]
|
||||
if !ok {
|
||||
log.Errorf("unknown repo type, are you sure you want to use GetCommonAPI?")
|
||||
ti = repo.FullNodeRepoType{}
|
||||
ti = repo.FullNode
|
||||
}
|
||||
t, ok := ti.(repo.RepoType)
|
||||
if !ok {
|
||||
|
@ -403,7 +403,7 @@ var clientRetrieveCatCmd = &cli.Command{
|
||||
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
|
||||
}
|
||||
|
||||
ainfo, err := GetAPIInfo(cctx, repo.FullNodeRepoType{})
|
||||
ainfo, err := GetAPIInfo(cctx, repo.FullNode)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("could not get API info: %w", err)
|
||||
}
|
||||
@ -482,7 +482,7 @@ var clientRetrieveLsCmd = &cli.Command{
|
||||
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
|
||||
}
|
||||
|
||||
ainfo, err := GetAPIInfo(cctx, repo.FullNodeRepoType{})
|
||||
ainfo, err := GetAPIInfo(cctx, repo.FullNode)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("could not get API info: %w", err)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ var PprofGoroutines = &cli.Command{
|
||||
ti, ok := cctx.App.Metadata["repoType"]
|
||||
if !ok {
|
||||
log.Errorf("unknown repo type, are you sure you want to use GetAPI?")
|
||||
ti = repo.FullNodeRepoType{}
|
||||
ti = repo.FullNode
|
||||
}
|
||||
t, ok := ti.(repo.RepoType)
|
||||
if !ok {
|
||||
|
@ -200,7 +200,7 @@ func GetCommonAPI(ctx *cli.Context) (api.CommonNet, jsonrpc.ClientCloser, error)
|
||||
ti, ok := ctx.App.Metadata["repoType"]
|
||||
if !ok {
|
||||
log.Errorf("unknown repo type, are you sure you want to use GetCommonAPI?")
|
||||
ti = repo.FullNodeRepoType{}
|
||||
ti = repo.FullNode
|
||||
}
|
||||
t, ok := ti.(repo.RepoType)
|
||||
if !ok {
|
||||
@ -232,7 +232,7 @@ func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, err
|
||||
return &v0api.WrapperV1Full{FullNode: tn.(v1api.FullNode)}, func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNodeRepoType{}, "v0")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -249,7 +249,7 @@ func GetFullNodeAPIV1(ctx *cli.Context) (v1api.FullNode, jsonrpc.ClientCloser, e
|
||||
return tn.(v1api.FullNode), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNodeRepoType{}, "v1")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -293,7 +293,7 @@ func GetStorageMinerAPI(ctx *cli.Context, opts ...GetStorageMinerOption) (api.St
|
||||
return tn.(api.StorageMiner), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.StorageMinerRepoType{}, "v0")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.StorageMiner, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -322,7 +322,7 @@ func GetStorageMinerAPI(ctx *cli.Context, opts ...GetStorageMinerOption) (api.St
|
||||
}
|
||||
|
||||
func GetWorkerAPI(ctx *cli.Context) (api.Worker, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.WorkerRepoType{}, "v0")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.Worker, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -340,7 +340,7 @@ func GetMarketsAPI(ctx *cli.Context) (api.StorageMiner, jsonrpc.ClientCloser, er
|
||||
return tn.(api.StorageMiner), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.MarketsRepoType{}, "v0")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.Markets, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -356,7 +356,7 @@ func GetMarketsAPI(ctx *cli.Context) (api.StorageMiner, jsonrpc.ClientCloser, er
|
||||
}
|
||||
|
||||
func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNodeRepoType{}, "v1")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -369,7 +369,7 @@ func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error)
|
||||
}
|
||||
|
||||
func GetGatewayAPIV0(ctx *cli.Context) (v0api.Gateway, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNodeRepoType{}, "v0")
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
||||
run := func(cmd *cli.Command, args ...string) error {
|
||||
app := cli.NewApp()
|
||||
app.Metadata = map[string]interface{}{
|
||||
"repoType": repo.StorageMinerRepoType{},
|
||||
"repoType": repo.StorageMiner,
|
||||
"testnode-full": client1,
|
||||
"testnode-storage": miner,
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func TestMinerAllInfo(t *testing.T) {
|
||||
run := func(t *testing.T) {
|
||||
app := cli.NewApp()
|
||||
app.Metadata = map[string]interface{}{
|
||||
"repoType": repo.StorageMinerRepoType{},
|
||||
"repoType": repo.StorageMiner,
|
||||
"testnode-full": client,
|
||||
"testnode-storage": miner,
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
|
||||
var backupCmd = lcli.BackupCmd(FlagMinerRepo, repo.StorageMinerRepoType{}, func(cctx *cli.Context) (lcli.BackupAPI, jsonrpc.ClientCloser, error) {
|
||||
var backupCmd = lcli.BackupCmd(FlagMinerRepo, repo.StorageMiner, func(cctx *cli.Context) (lcli.BackupAPI, jsonrpc.ClientCloser, error) {
|
||||
return lcli.GetStorageMinerAPI(cctx)
|
||||
})
|
||||
|
@ -66,7 +66,7 @@ var configUpdateCmd = &cli.Command{
|
||||
return xerrors.Errorf("repo not initialized")
|
||||
}
|
||||
|
||||
lr, err := r.LockRO(repo.StorageMinerRepoType{})
|
||||
lr, err := r.LockRO(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("locking repo: %w", err)
|
||||
}
|
||||
|
@ -203,12 +203,12 @@ var initCmd = &cli.Command{
|
||||
|
||||
log.Info("Initializing repo")
|
||||
|
||||
if err := r.Init(repo.StorageMinerRepoType{}); err != nil {
|
||||
if err := r.Init(repo.StorageMiner); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
{
|
||||
lr, err := r.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -410,7 +410,7 @@ func findMarketDealID(ctx context.Context, api v1api.FullNode, deal market2.Deal
|
||||
}
|
||||
|
||||
func storageMinerInit(ctx context.Context, cctx *cli.Context, api v1api.FullNode, r repo.Repo, ssize abi.SectorSize, gasPrice types.BigInt) error {
|
||||
lr, err := r.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -159,11 +159,11 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
|
||||
|
||||
log.Info("Initializing repo")
|
||||
|
||||
if err := r.Init(repo.StorageMinerRepoType{}); err != nil {
|
||||
if err := r.Init(repo.StorageMiner); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func main() {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.App.Metadata["repoType"] = repo.MarketsRepoType{}
|
||||
c.App.Metadata["repoType"] = repo.Markets
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ func main() {
|
||||
// this command is explicitly called on markets, inform
|
||||
// common commands by overriding the repoType.
|
||||
if c.Bool("call-on-markets") {
|
||||
c.App.Metadata["repoType"] = repo.MarketsRepoType{}
|
||||
c.App.Metadata["repoType"] = repo.Markets
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -164,7 +164,7 @@ func main() {
|
||||
},
|
||||
}
|
||||
app.Setup()
|
||||
app.Metadata["repoType"] = repo.StorageMinerRepoType{}
|
||||
app.Metadata["repoType"] = repo.StorageMiner
|
||||
lcli.RunApp(app)
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ var runCmd = &cli.Command{
|
||||
return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-miner init' to set it up", minerRepoPath)
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func main() {
|
||||
Commands: local,
|
||||
}
|
||||
app.Setup()
|
||||
app.Metadata["repoType"] = repo.WorkerRepoType{}
|
||||
app.Metadata["repoType"] = repo.Worker
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Warnf("%+v", err)
|
||||
@ -310,11 +310,11 @@ var runCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
if !ok {
|
||||
if err := r.Init(repo.WorkerRepoType{}); err != nil {
|
||||
if err := r.Init(repo.Worker); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.WorkerRepoType{})
|
||||
lr, err := r.Lock(repo.Worker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -359,7 +359,7 @@ var runCmd = &cli.Command{
|
||||
}
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.WorkerRepoType{})
|
||||
lr, err := r.Lock(repo.Worker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -397,7 +397,7 @@ var runCmd = &cli.Command{
|
||||
}
|
||||
|
||||
// Setup remote sector store
|
||||
sminfo, err := lcli.GetAPIInfo(cctx, repo.StorageMinerRepoType{})
|
||||
sminfo, err := lcli.GetAPIInfo(cctx, repo.StorageMiner)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("could not get api info: %w", err)
|
||||
}
|
||||
@ -484,7 +484,7 @@ var runCmd = &cli.Command{
|
||||
return xerrors.Errorf("setting api endpoint: %w", err)
|
||||
}
|
||||
|
||||
ainfo, err := lcli.GetAPIInfo(cctx, repo.StorageMinerRepoType{})
|
||||
ainfo, err := lcli.GetAPIInfo(cctx, repo.StorageMiner)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("could not get miner API info: %w", err)
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ var chainBalanceStateCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -710,7 +710,7 @@ var chainPledgeCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ var exportCarCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ var exportChainCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ var importCarCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -112,7 +112,7 @@ var importObjectCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ var keyinfoImportCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ func openLockedRepo(path string) (repo.LockedRepo, error) {
|
||||
}
|
||||
|
||||
// Lock the repo
|
||||
lr, err := rpo.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := rpo.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("locking repo %s: %w", path, err)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ var migrationsCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ var minerPeeridCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ var minerTypesCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ var stateTreePruneCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ var rpcCmd = &cli.Command{
|
||||
Action: func(cctx *cli.Context) error {
|
||||
var rt repo.RepoType
|
||||
if cctx.Bool("miner") {
|
||||
rt = repo.StorageMinerRepoType{}
|
||||
rt = repo.StorageMiner
|
||||
} else {
|
||||
rt = repo.FullNodeRepoType{}
|
||||
rt = repo.FullNode
|
||||
}
|
||||
|
||||
addr, headers, err := lcli.GetRawAPI(cctx, rt, cctx.String("version"))
|
||||
@ -125,7 +125,7 @@ var rpcCmd = &cli.Command{
|
||||
return send(cctx.Args().Get(0), params)
|
||||
}
|
||||
|
||||
cctx.App.Metadata["repoType"] = repo.FullNodeRepoType{}
|
||||
cctx.App.Metadata["repoType"] = repo.FullNode
|
||||
if err := lcli.VersionCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ var splitstoreRollbackCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error locking repo: %w", err)
|
||||
}
|
||||
@ -153,7 +153,7 @@ var splitstoreClearCmd = &cli.Command{
|
||||
return xerrors.Errorf("lotus repo doesn't exist")
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error locking repo: %w", err)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ var terminationsCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNodeRepoType{})
|
||||
lkrepo, err := fsrepo.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func OpenNode(ctx context.Context, path string) (*Node, error) {
|
||||
|
||||
// NewNode constructs a new node from the given repo.
|
||||
func NewNode(ctx context.Context, r repo.Repo) (nd *Node, _err error) {
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func openRepo(cctx *cli.Context) (repo.LockedRepo, types.KeyStore, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
if !ok {
|
||||
if err := r.Init(repo.WorkerRepoType{}); err != nil {
|
||||
if err := r.Init(repo.Worker); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
|
||||
var backupCmd = lcli.BackupCmd("repo", repo.FullNodeRepoType{}, func(cctx *cli.Context) (lcli.BackupAPI, jsonrpc.ClientCloser, error) {
|
||||
var backupCmd = lcli.BackupCmd("repo", repo.FullNode, func(cctx *cli.Context) (lcli.BackupAPI, jsonrpc.ClientCloser, error) {
|
||||
return lcli.GetFullNodeAPI(cctx)
|
||||
})
|
||||
|
||||
@ -39,7 +39,7 @@ func restore(cctx *cli.Context, r repo.Repo) error {
|
||||
}
|
||||
defer f.Close() // nolint:errcheck
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ var configUpdateCmd = &cli.Command{
|
||||
return xerrors.Errorf("repo not initialized")
|
||||
}
|
||||
|
||||
lr, err := r.LockRO(repo.FullNodeRepoType{})
|
||||
lr, err := r.LockRO(repo.FullNode)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("locking repo: %w", err)
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ var DaemonCmd = &cli.Command{
|
||||
r.SetConfigPath(cctx.String("config"))
|
||||
}
|
||||
|
||||
err = r.Init(repo.FullNodeRepoType{})
|
||||
err = r.Init(repo.FullNode)
|
||||
if err != nil && err != repo.ErrRepoExists {
|
||||
return xerrors.Errorf("repo init error: %w", err)
|
||||
}
|
||||
@ -462,7 +462,7 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool)
|
||||
l = st.Size()
|
||||
}
|
||||
|
||||
lr, err := r.Lock(repo.FullNodeRepoType{})
|
||||
lr, err := r.Lock(repo.FullNode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func main() {
|
||||
|
||||
app.Setup()
|
||||
app.Metadata["traceContext"] = ctx
|
||||
app.Metadata["repoType"] = repo.FullNodeRepoType{}
|
||||
app.Metadata["repoType"] = repo.FullNode
|
||||
|
||||
lcli.RunApp(app)
|
||||
}
|
||||
|
@ -341,8 +341,8 @@ FIXME: This section needs to be clarified / corrected...I don't fully understand
|
||||
|
||||
At the end of the `Repo()` function we see two mutually exclusive configuration calls based on the `RepoType` (`node/repo/fsrepo.go`).
|
||||
```Go
|
||||
ApplyIf(isType(repo.FullNodeRepoType{}), ConfigFullNode(c)),
|
||||
ApplyIf(isType(repo.StorageMinerRepoType{}), ConfigStorageMiner(c)),
|
||||
ApplyIf(isType(repo.FullNode), ConfigFullNode(c)),
|
||||
ApplyIf(isType(repo.StorageMiner), ConfigStorageMiner(c)),
|
||||
```
|
||||
As we said, the repo fully identifies the node so a repo type is also a *node* type, in this case a full node or a miner. (FIXME: What is the difference between the two, does *full* imply miner?) In this case the `daemon` command will create a `FullNode`, this is specified in the command logic itself in `main.DaemonCmd()`, the `FsRepo` created (and passed to `node.Repo()`) will be initiated with that type (see `(*FsRepo).Init(t RepoType)`).
|
||||
|
||||
@ -352,7 +352,7 @@ FIXME: Much of this might need to be subsumed into the p2p section
|
||||
|
||||
The `node.Online()` configuration function (`node/builder.go`) initializes components that involve connecting to,
|
||||
or interacting with, the Filecoin network. These connections are managed through the libp2p stack (FIXME link to this section when it exists).
|
||||
We discuss some of the components found in the full node type (that is, included in the `ApplyIf(isType(repo.FullNodeRepoType{}),` call).
|
||||
We discuss some of the components found in the full node type (that is, included in the `ApplyIf(isType(repo.FullNode),` call).
|
||||
|
||||
#### Chainstore
|
||||
|
||||
|
4
extern/sector-storage/stores/remote_test.go
vendored
4
extern/sector-storage/stores/remote_test.go
vendored
@ -73,8 +73,8 @@ func TestMoveShared(t *testing.T) {
|
||||
openRepo := func(dir string) repo.LockedRepo {
|
||||
r, err := repo.NewFS(dir)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, r.Init(repo.WorkerRepoType{}))
|
||||
lr, err := r.Lock(repo.WorkerRepoType{})
|
||||
require.NoError(t, r.Init(repo.Worker))
|
||||
lr, err := r.Lock(repo.Worker)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
|
@ -146,7 +146,7 @@ func TestSimultanenousTransferLimit(t *testing.T) {
|
||||
)
|
||||
runTest := func(t *testing.T) {
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ConstructorOpts(
|
||||
node.ApplyIf(node.IsType(repo.StorageMinerRepoType{}), node.Override(new(dtypes.StagingGraphsync), modules.StagingGraphsync(graphsyncThrottle, 0, graphsyncThrottle))),
|
||||
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.StagingGraphsync), modules.StagingGraphsync(graphsyncThrottle, 0, graphsyncThrottle))),
|
||||
node.Override(new(dtypes.Graphsync), modules.Graphsync(graphsyncThrottle, graphsyncThrottle)),
|
||||
))
|
||||
ens.InterconnectAll().BeginMining(250 * time.Millisecond)
|
||||
|
@ -443,7 +443,7 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
|
||||
r := repo.NewMemory(nil)
|
||||
|
||||
lr, err := r.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
require.NoError(n.t, err)
|
||||
|
||||
c, err := lr.Config()
|
||||
|
@ -35,7 +35,7 @@ func TestDealsWithFinalizeEarly(t *testing.T) {
|
||||
var blockTime = 50 * time.Millisecond
|
||||
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.ConstructorOpts(
|
||||
node.ApplyIf(node.IsType(repo.StorageMinerRepoType{}), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||
return func() (sealiface.Config, error) {
|
||||
cf := config.DefaultStorageMiner()
|
||||
cf.Sealing.FinalizeEarly = true
|
||||
|
@ -38,7 +38,7 @@ func TestMinerBalanceCollateral(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(
|
||||
node.ApplyIf(node.IsType(repo.StorageMinerRepoType{}), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||
return func() (sealiface.Config, error) {
|
||||
return sealiface.Config{
|
||||
MaxWaitDealsSectors: 4,
|
||||
|
@ -227,12 +227,12 @@ func IsType(t repo.RepoType) func(s *Settings) bool {
|
||||
return func(s *Settings) bool { return s.nodeType.Type() == t.Type() }
|
||||
}
|
||||
|
||||
func isFullOrLiteNode(s *Settings) bool { return s.nodeType.Type() == repo.FullNodeRepoType{}.Type() }
|
||||
func isFullOrLiteNode(s *Settings) bool { return s.nodeType.Type() == repo.FullNode.Type() }
|
||||
func isFullNode(s *Settings) bool {
|
||||
return s.nodeType.Type() == repo.FullNodeRepoType{}.Type() && !s.Lite
|
||||
return s.nodeType.Type() == repo.FullNode.Type() && !s.Lite
|
||||
}
|
||||
func isLiteNode(s *Settings) bool {
|
||||
return s.nodeType.Type() == repo.FullNodeRepoType{}.Type() && s.Lite
|
||||
return s.nodeType.Type() == repo.FullNode.Type() && s.Lite
|
||||
}
|
||||
|
||||
func Base() Option {
|
||||
@ -245,7 +245,7 @@ func Base() Option {
|
||||
LibP2P,
|
||||
),
|
||||
ApplyIf(isFullOrLiteNode, ChainNode),
|
||||
ApplyIf(IsType(repo.StorageMinerRepoType{}), MinerNode),
|
||||
ApplyIf(IsType(repo.StorageMiner), MinerNode),
|
||||
)
|
||||
}
|
||||
|
||||
@ -318,8 +318,8 @@ func Repo(r repo.Repo) Option {
|
||||
|
||||
Override(new(*dtypes.APIAlg), modules.APISecret),
|
||||
|
||||
ApplyIf(IsType(repo.FullNodeRepoType{}), ConfigFullNode(c)),
|
||||
ApplyIf(IsType(repo.StorageMinerRepoType{}), ConfigStorageMiner(c)),
|
||||
ApplyIf(IsType(repo.FullNode), ConfigFullNode(c)),
|
||||
ApplyIf(IsType(repo.StorageMiner), ConfigStorageMiner(c)),
|
||||
)(settings)
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ func Lite(enable bool) FullOption {
|
||||
func FullAPI(out *api.FullNode, fopts ...FullOption) Option {
|
||||
return Options(
|
||||
func(s *Settings) error {
|
||||
s.nodeType = repo.FullNodeRepoType{}
|
||||
s.nodeType = repo.FullNode
|
||||
s.enableLibp2pNode = true
|
||||
return nil
|
||||
},
|
||||
|
@ -221,7 +221,7 @@ func StorageMiner(out *api.StorageMiner, subsystemsCfg config.MinerSubsystemConf
|
||||
),
|
||||
|
||||
func(s *Settings) error {
|
||||
s.nodeType = repo.StorageMinerRepoType{}
|
||||
s.nodeType = repo.StorageMiner
|
||||
s.enableLibp2pNode = subsystemsCfg.EnableMarkets
|
||||
return nil
|
||||
},
|
||||
|
@ -44,11 +44,11 @@ const (
|
||||
func NewRepoTypeFromString(t string) RepoType {
|
||||
switch t {
|
||||
case "FullNode":
|
||||
return FullNodeRepoType{}
|
||||
return FullNode
|
||||
case "StorageMiner":
|
||||
return StorageMinerRepoType{}
|
||||
return StorageMiner
|
||||
case "Worker":
|
||||
return WorkerRepoType{}
|
||||
return Worker
|
||||
case "Wallet":
|
||||
return WalletRepoType{}
|
||||
default:
|
||||
@ -61,47 +61,55 @@ type RepoType interface {
|
||||
Config() interface{}
|
||||
}
|
||||
|
||||
type FullNodeRepoType struct {
|
||||
var FullNode fullNode
|
||||
|
||||
type fullNode struct {
|
||||
}
|
||||
|
||||
func (f FullNodeRepoType) Type() string {
|
||||
func (f fullNode) Type() string {
|
||||
return "FullNode"
|
||||
}
|
||||
|
||||
func (f FullNodeRepoType) Config() interface{} {
|
||||
func (f fullNode) Config() interface{} {
|
||||
return config.DefaultFullNode()
|
||||
}
|
||||
|
||||
type StorageMinerRepoType struct {
|
||||
var StorageMiner storageMiner
|
||||
|
||||
type storageMiner struct {
|
||||
}
|
||||
|
||||
func (f StorageMinerRepoType) Type() string {
|
||||
func (f storageMiner) Type() string {
|
||||
return "StorageMiner"
|
||||
}
|
||||
|
||||
func (f StorageMinerRepoType) Config() interface{} {
|
||||
func (f storageMiner) Config() interface{} {
|
||||
return config.DefaultStorageMiner()
|
||||
}
|
||||
|
||||
type MarketsRepoType struct {
|
||||
var Markets markets
|
||||
|
||||
type markets struct {
|
||||
}
|
||||
|
||||
func (f MarketsRepoType) Type() string {
|
||||
func (f markets) Type() string {
|
||||
return "Markets"
|
||||
}
|
||||
|
||||
func (f MarketsRepoType) Config() interface{} {
|
||||
func (f markets) Config() interface{} {
|
||||
return config.DefaultStorageMiner()
|
||||
}
|
||||
|
||||
type WorkerRepoType struct {
|
||||
type worker struct {
|
||||
}
|
||||
|
||||
func (f WorkerRepoType) Type() string {
|
||||
var Worker worker
|
||||
|
||||
func (f worker) Type() string {
|
||||
return "Worker"
|
||||
}
|
||||
|
||||
func (f WorkerRepoType) Config() interface{} {
|
||||
func (f worker) Config() interface{} {
|
||||
return &struct{}{}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ func genFsRepo(t *testing.T) (*FsRepo, func()) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = repo.Init(FullNodeRepoType{})
|
||||
err = repo.Init(FullNode)
|
||||
if err != ErrRepoExists && err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ func basicTest(t *testing.T, repo Repo) {
|
||||
}
|
||||
assert.Nil(t, apima, "with no api endpoint, return should be nil")
|
||||
|
||||
lrepo, err := repo.Lock(FullNodeRepoType{})
|
||||
lrepo, err := repo.Lock(FullNode)
|
||||
assert.NoError(t, err, "should be able to lock once")
|
||||
assert.NotNil(t, lrepo, "locked repo shouldn't be nil")
|
||||
|
||||
{
|
||||
lrepo2, err := repo.Lock(FullNodeRepoType{})
|
||||
lrepo2, err := repo.Lock(FullNode)
|
||||
if assert.Error(t, err) {
|
||||
assert.Equal(t, ErrRepoAlreadyLocked, err)
|
||||
}
|
||||
@ -36,7 +36,7 @@ func basicTest(t *testing.T, repo Repo) {
|
||||
err = lrepo.Close()
|
||||
assert.NoError(t, err, "should be able to unlock")
|
||||
|
||||
lrepo, err = repo.Lock(FullNodeRepoType{})
|
||||
lrepo, err = repo.Lock(FullNode)
|
||||
assert.NoError(t, err, "should be able to relock")
|
||||
assert.NotNil(t, lrepo, "locked repo shouldn't be nil")
|
||||
|
||||
@ -80,7 +80,7 @@ func basicTest(t *testing.T, repo Repo) {
|
||||
k1 := types.KeyInfo{Type: "foo"}
|
||||
k2 := types.KeyInfo{Type: "bar"}
|
||||
|
||||
lrepo, err = repo.Lock(FullNodeRepoType{})
|
||||
lrepo, err = repo.Lock(FullNode)
|
||||
assert.NoError(t, err, "should be able to relock")
|
||||
assert.NotNil(t, lrepo, "locked repo shouldn't be nil")
|
||||
|
||||
|
@ -138,7 +138,7 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = minerRepo.Init(repo.StorageMinerRepoType{})
|
||||
err = minerRepo.Init(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -146,7 +146,7 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
|
||||
var subsystems config.MinerSubsystemConfig
|
||||
|
||||
{
|
||||
lr, err := minerRepo.Lock(repo.StorageMinerRepoType{})
|
||||
lr, err := minerRepo.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -244,7 +244,7 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = nodeRepo.Init(repo.FullNodeRepoType{})
|
||||
err = nodeRepo.Init(repo.FullNode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user