Skip to content

Commit

Permalink
chore: add types for hyperswarm testnet (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Oct 17, 2022
1 parent e1b1b8b commit 9b576b7
Show file tree
Hide file tree
Showing 4 changed files with 619 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/discovery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class Discovery extends TypedEmitter {
* Handle connection that occur via the Hyperswarm DHT
*
* @private
* @param {NoiseSecretStream<RawDHTConnectionStream>} connection
* @param {NoiseSecretStream<RawDhtConnectionStream>} connection
* @param {HyperswarmPeerInfo} info
* @returns {Promise<void>}
*/
Expand Down
13 changes: 10 additions & 3 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@

// TODO: Figure out where those extra fields come from and find more elegant way to represent this
/**
* @typedef {import('streamx').Duplex & {remoteAddress: string, remotePort:number}} RawDHTConnectionStream
* @typedef {import('streamx').Duplex & {remoteAddress: string, remotePort:number}} RawDhtConnectionStream
*/

/**
* @typedef {import('net').Socket | RawDHTConnectionStream} RawConnectionStream
* @typedef {import('net').Socket | RawDhtConnectionStream} RawConnectionStream
*/

/**
Expand All @@ -68,11 +68,18 @@
* @typedef {import('events').EventEmitter & HyperswarmPeerInfoObject} HyperswarmPeerInfo
*/

/**
* @typedef {Object} DhtNode
*
* @property {string} host
* @property {number} port
*/

/**
* @typedef {Object} DhtOptions
* @property {Boolean} server
* @property {Boolean} client
* @property {Object[]} [bootstrap] Array of {host, port} objects provided by https://github.com/hyperswarm/testnet
* @property {DhtNode[]} [bootstrap] Array of {host, port} objects provided by https://github.com/hyperswarm/testnet
* @property {IdentityKeyPair} [keyPair]
*/

Expand Down
1 change: 1 addition & 0 deletions tests/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ test('discovery - valid connection discovery types', async (t) => {
})

for (const instance of instances) {
/** @type {string[]} */
const allowedDiscoveryTypes = []

if (instance.dhtActive) {
Expand Down
Loading

0 comments on commit 9b576b7

Please sign in to comment.