From 2fdbd1d1ae4caf2d7f7b08e3861f93e5424274df Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Wed, 20 Dec 2023 11:53:57 -0500 Subject: [PATCH] feat: add resource manager for separate DHT libp2p host --- setup.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.go b/setup.go index c3ecb0f..17ece4d 100644 --- a/setup.go +++ b/setup.go @@ -199,11 +199,18 @@ func Setup(ctx context.Context, cfg Config, key crypto.PrivKey, dnsCache *cached if cfg.DHTSharedHost { dhtHost = h } else { + dhtLimiter := rcmgr.NewFixedLimiter(makeResourceManagerConfig(cfg.MaxMemory, cfg.MaxFD, cfg.ConnMgrHi)) + dhtMgr, err := rcmgr.NewResourceManager(dhtLimiter) + if err != nil { + return nil, err + } + dhtHost, err = libp2p.New( libp2p.NoListenAddrs, libp2p.BandwidthReporter(bwc), libp2p.DefaultTransports, libp2p.DefaultMuxers, + libp2p.ResourceManager(dhtMgr), ) if err != nil { return nil, err