lotus/node/enable_libp2p.go
Anton Evangelatov 96245c3cfa lint
2021-07-02 12:02:36 +02:00

41 lines
789 B
Go

package node
import (
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
)
func ApplyIfEnableLibP2P(r repo.Repo, opts ...Option) Option {
return ApplyIf(func(settings *Settings) bool {
lr, err := r.Lock(settings.nodeType)
if err != nil {
// TODO: log error
return false
}
c, err := lr.Config()
if err != nil {
// TODO: log error
return false
}
defer lr.Close() //nolint:errcheck
switch settings.nodeType {
case repo.FullNode:
return true
case repo.StorageMiner:
cfg, ok := c.(*config.StorageMiner)
if !ok {
// TODO: log error
return false
}
enableLibP2P := cfg.Subsystems.EnableStorageMarket
return enableLibP2P
default:
// TODO: log error
return false
}
}, opts...)
}