@@ -4,16 +4,15 @@ import (
4
4
"context"
5
5
"fmt"
6
6
"sync"
7
- "time"
8
7
9
8
"github.com/libp2p/go-libp2p"
10
9
dht "github.com/libp2p/go-libp2p-kad-dht"
11
10
pubsub "github.com/libp2p/go-libp2p-pubsub"
12
11
"github.com/libp2p/go-libp2p/core/host"
13
12
"github.com/libp2p/go-libp2p/core/peer"
14
13
"github.com/libp2p/go-libp2p/p2p/discovery/routing"
14
+ rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
15
15
rhost "github.com/libp2p/go-libp2p/p2p/host/routed"
16
- "github.com/libp2p/go-libp2p/p2p/net/connmgr"
17
16
"github.com/multiformats/go-multiaddr"
18
17
"github.com/pkg/errors"
19
18
"github.com/rs/zerolog/log"
@@ -51,7 +50,6 @@ type Notifee interface {
51
50
type P2PNode struct {
52
51
config p2pNodeConfig
53
52
54
- connmngr * connmgr.BasicConnMgr
55
53
mux sync.Mutex
56
54
host host.Host
57
55
dht * dht.IpfsDHT
@@ -74,7 +72,6 @@ type p2pNodeConfig struct {
74
72
func NewP2PNode (config p2pNodeConfig ) * P2PNode {
75
73
p := P2PNode {
76
74
config : config ,
77
- connmngr : nil ,
78
75
host : nil ,
79
76
pubSub : nil ,
80
77
gossipRooms : make (map [string ]* gossipRoom ),
@@ -149,7 +146,7 @@ func (p *P2PNode) init(ctx context.Context) error {
149
146
if p .host != nil {
150
147
return errors .New ("Cannot create host on p2p with existing host" )
151
148
}
152
- p2pHost , hashTable , connectionManager , err := createHost (ctx , p .config )
149
+ p2pHost , hashTable , err := createHost (ctx , p .config )
153
150
if err != nil {
154
151
return err
155
152
}
@@ -160,7 +157,6 @@ func (p *P2PNode) init(ctx context.Context) error {
160
157
161
158
p .host = p2pHost
162
159
p .dht = hashTable
163
- p .connmngr = connectionManager
164
160
p .pubSub = p2pPubSub
165
161
log .Info ().Str ("address" , p .p2pAddress ()).Msg ("created libp2p host" )
166
162
return nil
@@ -169,24 +165,22 @@ func (p *P2PNode) init(ctx context.Context) error {
169
165
func createHost (
170
166
ctx context.Context ,
171
167
config p2pNodeConfig ,
172
- ) (host.Host , * dht.IpfsDHT , * connmgr. BasicConnMgr , error ) {
168
+ ) (host.Host , * dht.IpfsDHT , error ) {
173
169
var err error
174
170
175
- connectionManager , err := connmgr .NewConnManager (
176
- 160 , // Lowwater
177
- 192 , // HighWater,
178
- connmgr .WithGracePeriod (time .Minute ),
179
- )
180
- if err != nil {
181
- return nil , nil , nil , err
182
- }
171
+ // NOTE:
172
+ // Upon initialization, we are seeing log warnings:
173
+ // "rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1"
174
+ //
175
+ // This was a bug in the check function, reading the wrong config value to check against:
176
+ // https://github.com/libp2p/go-libp2p/issues/2628
183
177
184
178
options := []libp2p.Option {
185
179
libp2p .Identity (& config .PrivKey .Key ),
186
180
libp2p .ListenAddrs (config .ListenAddrs ... ),
187
- libp2p .DefaultTransports ,
188
- libp2p .DefaultSecurity ,
189
- libp2p .ConnectionManager (connectionManager ),
181
+ // libp2p.DefaultTransports,
182
+ // libp2p.DefaultSecurity,
183
+ // libp2p.ConnectionManager(connectionManager),
190
184
libp2p .ProtocolVersion (protocolVersion ),
191
185
}
192
186
@@ -204,23 +198,23 @@ func createHost(
204
198
205
199
p2pHost , err := libp2p .New (options ... )
206
200
if err != nil {
207
- return nil , nil , nil , err
201
+ return nil , nil , err
208
202
}
209
203
210
204
if config .DisableRoutingDHT {
211
- return p2pHost , nil , connectionManager , err
205
+ return p2pHost , nil , err
212
206
}
213
207
214
208
opts := dhtRoutingOptions (config .Environment , config .BootstrapPeers ... )
215
209
idht , err := dht .New (ctx , p2pHost , opts ... )
216
210
if err != nil {
217
- return nil , nil , nil , err
211
+ return nil , nil , err
218
212
}
219
213
// the wrapped host will try to query the routing table (dht)/
220
214
// whenever it doesn't have the full routed address for a peer id
221
215
routedHost := rhost .Wrap (p2pHost , idht )
222
216
223
- return routedHost , idht , connectionManager , nil
217
+ return routedHost , idht , nil
224
218
}
225
219
226
220
func createPubSub (
0 commit comments