@@ -13,7 +13,7 @@ const PubsubRouters = require('../runtime/libp2p-pubsub-routers-nodejs')
13
13
* @typedef {import('peer-id') } PeerId
14
14
* @typedef {import('../types').Options } IPFSOptions
15
15
* @typedef {import('libp2p') } LibP2P
16
- * @typedef {import('libp2p').Libp2pOptions & import('libp2p').constructorOptions } Options
16
+ * @typedef {import('libp2p').Libp2pOptions & import('libp2p').constructorOptions } Libp2pOptions
17
17
* @typedef {import('ipfs-core-types/src/config').Config } IPFSConfig
18
18
* @typedef {import('multiaddr').Multiaddr } Multiaddr
19
19
*/
@@ -93,25 +93,20 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
93
93
config : {
94
94
peerDiscovery : {
95
95
mdns : {
96
- enabled : get ( options , 'config.Discovery.MDNS.Enabled' ,
97
- get ( config , 'Discovery.MDNS.Enabled' , true ) )
96
+ enabled : get ( options , 'config.Discovery.MDNS.Enabled' , get ( config , 'Discovery.MDNS.Enabled' , true ) )
98
97
} ,
99
98
webRTCStar : {
100
- enabled : get ( options , 'config.Discovery.webRTCStar.Enabled' ,
101
- get ( config , 'Discovery.webRTCStar.Enabled' , true ) )
99
+ enabled : get ( options , 'config.Discovery.webRTCStar.Enabled' , get ( config , 'Discovery.webRTCStar.Enabled' , true ) )
102
100
} ,
103
101
bootstrap : {
104
102
list : get ( options , 'config.Bootstrap' , get ( config , 'Bootstrap' , [ ] ) )
105
103
}
106
104
} ,
107
105
relay : {
108
- enabled : get ( options , 'relay.enabled' ,
109
- get ( config , 'relay.enabled' , true ) ) ,
106
+ enabled : get ( options , 'relay.enabled' , get ( config , 'relay.enabled' , true ) ) ,
110
107
hop : {
111
- enabled : get ( options , 'relay.hop.enabled' ,
112
- get ( config , 'relay.hop.enabled' , false ) ) ,
113
- active : get ( options , 'relay.hop.active' ,
114
- get ( config , 'relay.hop.active' , false ) )
108
+ enabled : get ( options , 'relay.hop.enabled' , get ( config , 'relay.hop.enabled' , false ) ) ,
109
+ active : get ( options , 'relay.hop.active' , get ( config , 'relay.hop.active' , false ) )
115
110
}
116
111
} ,
117
112
dht : {
@@ -120,30 +115,20 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
120
115
kBucketSize : get ( options , 'dht.kBucketSize' , 20 )
121
116
} ,
122
117
pubsub : {
123
- enabled : get ( options , 'config.Pubsub.Enabled' ,
124
- get ( config , 'Pubsub.Enabled' , true ) )
118
+ enabled : get ( options , 'config.Pubsub.Enabled' , get ( config , 'Pubsub.Enabled' , true ) )
125
119
} ,
126
120
nat : {
127
- enabled : get ( options , 'libp2p.config.nat.enabled' , ! get ( config , 'Swarm.DisableNatPortMap' , false ) ) ,
128
- ttl : get ( options , 'libp2p.config.nat.ttl' , 7200 ) ,
129
- keepAlive : get ( options , 'libp2p.config.nat.keepAlive' , true ) ,
130
- gateway : get ( options , 'libp2p.config.nat.gateway' ) ,
131
- externalIp : get ( options , 'libp2p.config.nat.externalIp' ) ,
132
- pmp : {
133
- enabled : get ( options , 'libp2p.config.nat.pmp.enabled' , false )
134
- }
121
+ enabled : ! get ( config , 'Swarm.DisableNatPortMap' , false )
135
122
}
136
123
} ,
137
124
addresses : {
138
125
listen : multiaddrs . map ( ma => ma . toString ( ) ) ,
139
- announce : get ( options , 'addresses.announce' ,
140
- get ( config , 'Addresses.Announce ' , [ ] ) )
126
+ announce : get ( options , 'addresses.announce' , get ( config , 'Addresses.Announce' , [ ] ) ) ,
127
+ noAnnounce : get ( options , 'addresses.noAnnounce' , get ( config , 'Addresses.NoAnnounce ' , [ ] ) )
141
128
} ,
142
129
connectionManager : get ( options , 'connectionManager' , {
143
- maxConnections : get ( options , 'config.Swarm.ConnMgr.HighWater' ,
144
- get ( config , 'Swarm.ConnMgr.HighWater' ) ) ,
145
- minConnections : get ( options , 'config.Swarm.ConnMgr.LowWater' ,
146
- get ( config , 'Swarm.ConnMgr.LowWater' ) )
130
+ maxConnections : get ( options , 'config.Swarm.ConnMgr.HighWater' , get ( config , 'Swarm.ConnMgr.HighWater' ) ) ,
131
+ minConnections : get ( options , 'config.Swarm.ConnMgr.LowWater' , get ( config , 'Swarm.ConnMgr.LowWater' ) )
147
132
} ) ,
148
133
keychain : {
149
134
datastore : keys ,
@@ -155,10 +140,11 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
155
140
// Note: libp2p-nodejs gets replaced by libp2p-browser when webpacked/browserified
156
141
const getEnvLibp2pOptions = require ( '../runtime/libp2p-nodejs' )
157
142
158
- let constructorOptions = get ( options , 'libp2p' , { } )
143
+ /** @type {import('libp2p').Libp2pOptions | undefined } */
144
+ let constructorOptions = get ( options , 'libp2p' , undefined )
159
145
160
146
if ( typeof constructorOptions === 'function' ) {
161
- constructorOptions = { }
147
+ constructorOptions = undefined
162
148
}
163
149
164
150
// Merge defaults with Node.js/browser/other environments options and configuration
0 commit comments