Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 326404b

Browse files
committed
fix: update types after feedback from ceramic
Some of the types need a little correcting. Fixes #3640
1 parent 7e61fbf commit 326404b

File tree

8 files changed

+24
-37
lines changed

8 files changed

+24
-37
lines changed

examples/custom-ipfs-repo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"datastore-fs": "4.0.0",
1414
"ipfs": "^0.54.4",
15-
"ipfs-repo": "^9.1.1",
15+
"ipfs-repo": "^9.1.3",
1616
"it-all": "^1.0.4"
1717
},
1818
"devDependencies": {

packages/ipfs-cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"ipfs-core-utils": "^0.7.2",
4343
"ipfs-daemon": "^0.5.4",
4444
"ipfs-http-client": "^49.0.4",
45-
"ipfs-repo": "^9.1.1",
45+
"ipfs-repo": "^9.1.3",
4646
"ipfs-utils": "^6.0.4",
4747
"ipld-dag-cbor": "^1.0.0",
4848
"ipld-dag-pb": "^0.22.1",

packages/ipfs-core-types/src/config/index.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export interface AddressConfig {
5151
RPC?: string
5252
Delegates?: string[]
5353
Gateway?: string
54-
Swarm?: string[]
54+
Swarm?: string[],
55+
Announce?: string[],
56+
NoAnnounce?: string[]
5557
}
5658

5759
export interface APIConfig {

packages/ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"ipfs-block-service": "^0.19.0",
7575
"ipfs-core-types": "^0.3.1",
7676
"ipfs-core-utils": "^0.7.2",
77-
"ipfs-repo": "^9.1.1",
77+
"ipfs-repo": "^9.1.3",
7878
"ipfs-unixfs": "^4.0.3",
7979
"ipfs-unixfs-exporter": "^5.0.3",
8080
"ipfs-unixfs-importer": "^7.0.3",

packages/ipfs-core/src/components/libp2p.js

+15-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const PubsubRouters = require('../runtime/libp2p-pubsub-routers-nodejs')
1313
* @typedef {import('peer-id')} PeerId
1414
* @typedef {import('../types').Options} IPFSOptions
1515
* @typedef {import('libp2p')} LibP2P
16-
* @typedef {import('libp2p').Libp2pOptions & import('libp2p').constructorOptions} Options
16+
* @typedef {import('libp2p').Libp2pOptions & import('libp2p').constructorOptions} Libp2pOptions
1717
* @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig
1818
* @typedef {import('multiaddr').Multiaddr} Multiaddr
1919
*/
@@ -93,25 +93,20 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
9393
config: {
9494
peerDiscovery: {
9595
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))
9897
},
9998
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))
102100
},
103101
bootstrap: {
104102
list: get(options, 'config.Bootstrap', get(config, 'Bootstrap', []))
105103
}
106104
},
107105
relay: {
108-
enabled: get(options, 'relay.enabled',
109-
get(config, 'relay.enabled', true)),
106+
enabled: get(options, 'relay.enabled', get(config, 'relay.enabled', true)),
110107
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))
115110
}
116111
},
117112
dht: {
@@ -120,30 +115,20 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
120115
kBucketSize: get(options, 'dht.kBucketSize', 20)
121116
},
122117
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))
125119
},
126120
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)
135122
}
136123
},
137124
addresses: {
138125
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', []))
141128
},
142129
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'))
147132
}),
148133
keychain: {
149134
datastore: keys,
@@ -155,10 +140,11 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p
155140
// Note: libp2p-nodejs gets replaced by libp2p-browser when webpacked/browserified
156141
const getEnvLibp2pOptions = require('../runtime/libp2p-nodejs')
157142

158-
let constructorOptions = get(options, 'libp2p', {})
143+
/** @type {import('libp2p').Libp2pOptions | undefined} */
144+
let constructorOptions = get(options, 'libp2p', undefined)
159145

160146
if (typeof constructorOptions === 'function') {
161-
constructorOptions = {}
147+
constructorOptions = undefined
162148
}
163149

164150
// Merge defaults with Node.js/browser/other environments options and configuration

packages/ipfs-core/src/components/network.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ class Network {
4848
await repo.open()
4949
}
5050

51+
/** @type {IPFSConfig} */
5152
const config = await repo.config.getAll()
5253

5354
const libp2p = await createLibP2P({
5455
options,
5556
repo,
5657
peerId,
57-
// @ts-ignore - TODO move config types into ipfs-repo
5858
multiaddrs: readAddrs(peerId, config),
59-
// @ts-ignore - TODO move config types into ipfs-repo
6059
config,
6160
keychainConfig: undefined
6261
})
@@ -90,10 +89,8 @@ class Network {
9089
module.exports = Network
9190

9291
/**
93-
*
9492
* @param {PeerId} peerId
9593
* @param {IPFSConfig} config
96-
* @returns {Multiaddr[]}
9794
*/
9895
const readAddrs = (peerId, config) => {
9996
const peerIdStr = peerId.toB58String()

packages/ipfs-core/src/runtime/config-browser.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = () => ({
55
Swarm: [
66
],
77
Announce: [],
8+
NoAnnounce: [],
89
API: '',
910
Gateway: '',
1011
RPC: '',

packages/ipfs-core/src/runtime/config-nodejs.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = () => ({
77
'/ip4/127.0.0.1/tcp/4003/ws'
88
],
99
Announce: [],
10+
NoAnnounce: [],
1011
API: '/ip4/127.0.0.1/tcp/5002',
1112
Gateway: '/ip4/127.0.0.1/tcp/9090',
1213
RPC: '/ip4/127.0.0.1/tcp/5003',

0 commit comments

Comments
 (0)