From 9ac2e2b98b8f6f5e7c577b21d292ba8406f2d31c 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