Skip to content

Commit

Permalink
feat: resource manage use json file
Browse files Browse the repository at this point in the history
  • Loading branch information
cody committed Oct 28, 2024
1 parent c938962 commit c609529
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/node/libp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package libp2p

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/benbjohnson/clock"
serialize "github.com/bittorrent/go-btfs-config/serialize"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/network"
Expand Down Expand Up @@ -56,6 +58,18 @@ func ResourceManager(cfg config.SwarmConfig) interface{} {
return nil, opts, err
}

partialLimitConfig := rcmgr.PartialLimitConfig{}
err = serialize.ReadConfigFile(filepath.Join(repoPath, "libp2p-resource-limit-overrides.json"), &partialLimitConfig)
if errors.Is(err, serialize.ErrNotInitialized) {
err = nil
} else {
if err != nil {
return nil, opts, err
}
}

limitConfig = partialLimitConfig.Build(limitConfig)

// The logic for defaults and overriding with specified SwarmConfig.ResourceMgr.Limits
// is documented in docs/config.md.
// Any changes here should be reflected there.
Expand Down

0 comments on commit c609529

Please sign in to comment.