Skip to content

Commit

Permalink
Merge pull request #8769 from filecoin-project/feat/rcmgr-for-daemon
Browse files Browse the repository at this point in the history
feat: only enable rcmgr by default in full nodes
  • Loading branch information
magik6k authored May 31, 2022
2 parents 000b932 + 207ff66 commit 9de9c58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions node/modules/lp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions node/repo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions node/repo/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions node/repo/memrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9de9c58

Please sign in to comment.