diff --git a/node/modules/lp2p/rcmgr.go b/node/modules/lp2p/rcmgr.go index 13d97418a..b82169393 100644 --- a/node/modules/lp2p/rcmgr.go +++ b/node/modules/lp2p/rcmgr.go @@ -27,9 +27,10 @@ import ( func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) { return func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) { + isFullNode := repo.RepoType().Type() == "FullNode" envvar := os.Getenv("LOTUS_RCMGR") - if envvar == "0" { - // this is enabled by default; specify LOTUS_RCMGR=0 to disable + if (isFullNode && envvar == "0") || // only set NullResourceManager if envvar is explicitly "0" + (!isFullNode && envvar != "1") { // set NullResourceManager *unless* envvar is explicitly "1" log.Info("libp2p resource manager is disabled") return network.NullResourceManager, nil } diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index 9688a518b..25c3e269e 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -417,6 +417,10 @@ type fsLockedRepo struct { configLk sync.Mutex } +func (fsr *fsLockedRepo) RepoType() RepoType { + return fsr.repoType +} + func (fsr *fsLockedRepo) Readonly() bool { return fsr.readonly } diff --git a/node/repo/interface.go b/node/repo/interface.go index b169ee5cc..904511634 100644 --- a/node/repo/interface.go +++ b/node/repo/interface.go @@ -52,6 +52,9 @@ type LockedRepo interface { // Close closes repo and removes lock. Close() error + // returns the type of this repo + RepoType() RepoType + // Returns datastore defined in this repo. // The supplied context must only be used to initialize the datastore. // The implementation should not retain the context for usage throughout diff --git a/node/repo/memrepo.go b/node/repo/memrepo.go index baff37d55..1b2e59c66 100644 --- a/node/repo/memrepo.go +++ b/node/repo/memrepo.go @@ -55,6 +55,10 @@ type lockedMemRepo struct { token *byte } +func (lmem *lockedMemRepo) RepoType() RepoType { + return lmem.t +} + func (lmem *lockedMemRepo) GetStorage() (stores.StorageConfig, error) { if err := lmem.checkToken(); err != nil { return stores.StorageConfig{}, err