2021-06-24 14:02:51 +00:00
|
|
|
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 {
|
2021-07-02 10:02:36 +00:00
|
|
|
// TODO: log error
|
2021-06-24 14:02:51 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
c, err := lr.Config()
|
|
|
|
if err != nil {
|
2021-07-02 10:02:36 +00:00
|
|
|
// TODO: log error
|
2021-06-24 14:02:51 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-07-02 10:02:36 +00:00
|
|
|
defer lr.Close() //nolint:errcheck
|
2021-06-24 14:02:51 +00:00
|
|
|
|
|
|
|
switch settings.nodeType {
|
|
|
|
case repo.FullNode:
|
|
|
|
return true
|
|
|
|
case repo.StorageMiner:
|
|
|
|
cfg, ok := c.(*config.StorageMiner)
|
|
|
|
if !ok {
|
2021-07-02 10:02:36 +00:00
|
|
|
// TODO: log error
|
2021-06-24 14:02:51 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
enableLibP2P := cfg.Subsystems.EnableStorageMarket
|
|
|
|
return enableLibP2P
|
|
|
|
default:
|
2021-07-02 10:02:36 +00:00
|
|
|
// TODO: log error
|
2021-06-24 14:02:51 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}, opts...)
|
|
|
|
}
|