Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit bf7d1ba

Browse files
dependabot[bot]maschadachingbrain
authored
deps(dev): bump aegir from 37.12.1 to 38.1.7 (#427)
Bumps [aegir](https://github.com/ipfs/aegir) from 37.12.1 to 38.1.7. --------- Co-authored-by: chad <[email protected]> Co-authored-by: achingbrain <[email protected]>
1 parent 2578533 commit bf7d1ba

39 files changed

+191
-188
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"test:chrome-webworker": "aegir test -t webworker",
138138
"test:firefox": "aegir test -t browser -- --browser firefox",
139139
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
140-
"dep-check": "aegir dep-check",
140+
"dep-check": "aegir dep-check -i protons",
141141
"release": "aegir release",
142142
"docs": "aegir docs"
143143
},
@@ -163,7 +163,6 @@
163163
"abortable-iterator": "^4.0.2",
164164
"any-signal": "^3.0.0",
165165
"datastore-core": "^8.0.1",
166-
"events": "^3.3.0",
167166
"hashlru": "^2.3.0",
168167
"interface-datastore": "^7.0.0",
169168
"it-all": "^2.0.0",
@@ -196,13 +195,12 @@
196195
"@types/lodash.range": "^3.2.6",
197196
"@types/varint": "^6.0.0",
198197
"@types/which": "^2.0.1",
199-
"aegir": "^37.7.7",
198+
"aegir": "^38.1.2",
200199
"datastore-level": "^9.0.0",
201200
"delay": "^5.0.0",
202201
"execa": "^6.0.0",
203202
"it-filter": "^2.0.0",
204203
"it-last": "^2.0.0",
205-
"it-pair": "^2.0.2",
206204
"lodash.random": "^3.2.0",
207205
"lodash.range": "^3.2.0",
208206
"p-retry": "^5.0.0",

src/content-fetching/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '../constants.js'
1717
import { createPutRecord, convertBuffer, bufferToRecordKey } from '../utils.js'
1818
import { logger } from '@libp2p/logger'
19-
import type { Validators, Selectors, ValueEvent, QueryOptions } from '@libp2p/interface-dht'
19+
import type { Validators, Selectors, ValueEvent, QueryOptions, QueryEvent } from '@libp2p/interface-dht'
2020
import type { PeerRouting } from '../peer-routing/index.js'
2121
import type { QueryManager } from '../query/manager.js'
2222
import type { RoutingTable } from '../routing-table/index.js'
@@ -59,7 +59,7 @@ export class ContentFetching {
5959
this.network = network
6060
}
6161

62-
async putLocal (key: Uint8Array, rec: Uint8Array) { // eslint-disable-line require-await
62+
async putLocal (key: Uint8Array, rec: Uint8Array): Promise<void> {
6363
const dsKey = bufferToRecordKey(key)
6464
await this.components.datastore.put(dsKey, rec)
6565
}
@@ -68,7 +68,7 @@ export class ContentFetching {
6868
* Attempt to retrieve the value for the given key from
6969
* the local datastore
7070
*/
71-
async getLocal (key: Uint8Array) {
71+
async getLocal (key: Uint8Array): Promise<Libp2pRecord> {
7272
this.log('getLocal %b', key)
7373

7474
const dsKey = bufferToRecordKey(key)
@@ -88,9 +88,9 @@ export class ContentFetching {
8888
/**
8989
* Send the best record found to any peers that have an out of date record
9090
*/
91-
async * sendCorrectionRecord (key: Uint8Array, vals: ValueEvent[], best: Uint8Array, options: AbortOptions = {}) {
91+
async * sendCorrectionRecord (key: Uint8Array, vals: ValueEvent[], best: Uint8Array, options: AbortOptions = {}): AsyncGenerator<QueryEvent> {
9292
this.log('sendCorrection for %b', key)
93-
const fixupRec = await createPutRecord(key, best)
93+
const fixupRec = createPutRecord(key, best)
9494

9595
for (const { value, from } of vals) {
9696
// no need to do anything
@@ -136,11 +136,11 @@ export class ContentFetching {
136136
/**
137137
* Store the given key/value pair in the DHT
138138
*/
139-
async * put (key: Uint8Array, value: Uint8Array, options: AbortOptions = {}) {
139+
async * put (key: Uint8Array, value: Uint8Array, options: AbortOptions = {}): AsyncGenerator<unknown, void, undefined> {
140140
this.log('put key %b value %b', key, value)
141141

142142
// create record in the dht format
143-
const record = await createPutRecord(key, value)
143+
const record = createPutRecord(key, value)
144144

145145
// store the record locally
146146
const dsKey = bufferToRecordKey(key)
@@ -192,7 +192,7 @@ export class ContentFetching {
192192
/**
193193
* Get the value to the given key
194194
*/
195-
async * get (key: Uint8Array, options: QueryOptions = {}) {
195+
async * get (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent | ValueEvent> {
196196
this.log('get %b', key)
197197

198198
const vals: ValueEvent[] = []
@@ -236,7 +236,7 @@ export class ContentFetching {
236236
/**
237237
* Get the `n` values to the given key without sorting
238238
*/
239-
async * getMany (key: Uint8Array, options: QueryOptions = {}) {
239+
async * getMany (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
240240
this.log('getMany values for %b', key)
241241

242242
try {

src/content-routing/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
providerEvent
1111
} from '../query/events.js'
1212
import { logger } from '@libp2p/logger'
13-
import type { QueryEvent, QueryOptions } from '@libp2p/interface-dht'
13+
import type { PeerResponseEvent, ProviderEvent, QueryEvent, QueryOptions } from '@libp2p/interface-dht'
1414
import type { PeerRouting } from '../peer-routing/index.js'
1515
import type { QueryManager } from '../query/manager.js'
1616
import type { RoutingTable } from '../routing-table/index.js'
@@ -58,7 +58,7 @@ export class ContentRouting {
5858
* Announce to the network that we can provide the value for a given key and
5959
* are contactable on the given multiaddrs
6060
*/
61-
async * provide (key: CID, multiaddrs: Multiaddr[], options: AbortOptions = {}) {
61+
async * provide (key: CID, multiaddrs: Multiaddr[], options: AbortOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
6262
this.log('provide %s', key)
6363

6464
// Add peer as provider
@@ -124,7 +124,7 @@ export class ContentRouting {
124124
/**
125125
* Search the dht for up to `K` providers of the given CID.
126126
*/
127-
async * findProviders (key: CID, options: QueryOptions) {
127+
async * findProviders (key: CID, options: QueryOptions): AsyncGenerator<PeerResponseEvent | ProviderEvent | QueryEvent> {
128128
const toFind = this.routingTable.kBucketSize
129129
const target = key.multihash.bytes
130130
const id = await convertBuffer(target)
@@ -147,7 +147,7 @@ export class ContentRouting {
147147
}
148148

149149
yield peerResponseEvent({ from: this.components.peerId, messageType: MESSAGE_TYPE.GET_PROVIDERS, providers })
150-
yield providerEvent({ from: this.components.peerId, providers: providers })
150+
yield providerEvent({ from: this.components.peerId, providers })
151151
}
152152

153153
// All done

src/dual-kad-dht.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CodeError } from '@libp2p/interfaces/errors'
33
import merge from 'it-merge'
44
import { queryErrorEvent } from './query/events.js'
55
import type { KadDHT } from './kad-dht.js'
6-
import type { DualDHT, QueryOptions } from '@libp2p/interface-dht'
6+
import type { DualDHT, QueryEvent, QueryOptions } from '@libp2p/interface-dht'
77
import type { AbortOptions } from '@libp2p/interfaces'
88
import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
99
import type { CID } from 'multiformats'
@@ -47,35 +47,35 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
4747
return true
4848
}
4949

50-
get [Symbol.toStringTag] () {
50+
get [Symbol.toStringTag] (): '@libp2p/dual-kad-dht' {
5151
return '@libp2p/dual-kad-dht'
5252
}
5353

5454
/**
5555
* Is this DHT running.
5656
*/
57-
isStarted () {
57+
isStarted (): boolean {
5858
return this.wan.isStarted() && this.lan.isStarted()
5959
}
6060

6161
/**
6262
* If 'server' this node will respond to DHT queries, if 'client' this node will not
6363
*/
64-
async getMode () {
64+
async getMode (): Promise<'client' | 'server'> {
6565
return await this.wan.getMode()
6666
}
6767

6868
/**
6969
* If 'server' this node will respond to DHT queries, if 'client' this node will not
7070
*/
71-
async setMode (mode: 'client' | 'server') {
71+
async setMode (mode: 'client' | 'server'): Promise<void> {
7272
await this.wan.setMode(mode)
7373
}
7474

7575
/**
7676
* Start listening to incoming connections.
7777
*/
78-
async start () {
78+
async start (): Promise<void> {
7979
await Promise.all([
8080
this.lan.start(),
8181
this.wan.start()
@@ -86,7 +86,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
8686
* Stop accepting incoming connections and sending outgoing
8787
* messages.
8888
*/
89-
async stop () {
89+
async stop (): Promise<void> {
9090
await Promise.all([
9191
this.lan.stop(),
9292
this.wan.stop()
@@ -96,7 +96,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
9696
/**
9797
* Store the given key/value pair in the DHT
9898
*/
99-
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}) {
99+
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
100100
for await (const event of merge(
101101
this.lan.put(key, value, options),
102102
this.wan.put(key, value, options)
@@ -108,7 +108,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
108108
/**
109109
* Get the value that corresponds to the passed key
110110
*/
111-
async * get (key: Uint8Array, options: QueryOptions = {}) { // eslint-disable-line require-await
111+
async * get (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
112112
let queriedPeers = false
113113
let foundValue = false
114114

@@ -152,7 +152,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
152152
/**
153153
* Announce to the network that we can provide given key's value
154154
*/
155-
async * provide (key: CID, options: AbortOptions = {}) { // eslint-disable-line require-await
155+
async * provide (key: CID, options: AbortOptions = {}): AsyncGenerator<QueryEvent> {
156156
let sent = 0
157157
let success = 0
158158
const errors = []
@@ -194,7 +194,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
194194
/**
195195
* Search the dht for up to `K` providers of the given CID
196196
*/
197-
async * findProviders (key: CID, options: QueryOptions = {}) {
197+
async * findProviders (key: CID, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
198198
yield * merge(
199199
this.lan.findProviders(key, options),
200200
this.wan.findProviders(key, options)
@@ -206,7 +206,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
206206
/**
207207
* Search for a peer with the given ID
208208
*/
209-
async * findPeer (id: PeerId, options: QueryOptions = {}) {
209+
async * findPeer (id: PeerId, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
210210
let queriedPeers = false
211211

212212
for await (const event of merge(
@@ -228,14 +228,14 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
228228
/**
229229
* Kademlia 'node lookup' operation
230230
*/
231-
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}) {
231+
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
232232
yield * merge(
233233
this.lan.getClosestPeers(key, options),
234234
this.wan.getClosestPeers(key, options)
235235
)
236236
}
237237

238-
async refreshRoutingTable () {
238+
async refreshRoutingTable (): Promise<void> {
239239
await Promise.all([
240240
this.lan.refreshRoutingTable(),
241241
this.wan.refreshRoutingTable()

src/kad-dht.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
removePublicAddresses
1515
} from './utils.js'
1616
import { Logger, logger } from '@libp2p/logger'
17-
import type { QueryOptions, Validators, Selectors, DHT } from '@libp2p/interface-dht'
17+
import type { QueryOptions, Validators, Selectors, DHT, QueryEvent } from '@libp2p/interface-dht'
1818
import type { PeerInfo } from '@libp2p/interface-peer-info'
1919
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
2020
import type { PeerId } from '@libp2p/interface-peer-id'
@@ -207,11 +207,11 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
207207
return true
208208
}
209209

210-
get [Symbol.toStringTag] () {
210+
get [Symbol.toStringTag] (): '@libp2p/kad-dht' {
211211
return '@libp2p/kad-dht'
212212
}
213213

214-
async onPeerConnect (peerData: PeerInfo) {
214+
async onPeerConnect (peerData: PeerInfo): Promise<void> {
215215
this.log('peer %p connected with protocols %s', peerData.id, peerData.protocols)
216216

217217
if (this.lan) {
@@ -235,21 +235,21 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
235235
/**
236236
* Is this DHT running.
237237
*/
238-
isStarted () {
238+
isStarted (): boolean {
239239
return this.running
240240
}
241241

242242
/**
243243
* If 'server' this node will respond to DHT queries, if 'client' this node will not
244244
*/
245-
async getMode () {
245+
async getMode (): Promise<'client' | 'server'> {
246246
return this.clientMode ? 'client' : 'server'
247247
}
248248

249249
/**
250250
* If 'server' this node will respond to DHT queries, if 'client' this node will not
251251
*/
252-
async setMode (mode: 'client' | 'server') {
252+
async setMode (mode: 'client' | 'server'): Promise<void> {
253253
await this.components.registrar.unhandle(this.protocol)
254254

255255
if (mode === 'client') {
@@ -268,7 +268,7 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
268268
/**
269269
* Start listening to incoming connections.
270270
*/
271-
async start () {
271+
async start (): Promise<void> {
272272
this.running = true
273273

274274
// Only respond to queries when not in client mode
@@ -290,7 +290,7 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
290290
* Stop accepting incoming connections and sending outgoing
291291
* messages.
292292
*/
293-
async stop () {
293+
async stop (): Promise<void> {
294294
this.running = false
295295

296296
await Promise.all([
@@ -307,14 +307,14 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
307307
/**
308308
* Store the given key/value pair in the DHT
309309
*/
310-
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}) { // eslint-disable-line require-await
310+
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}): AsyncGenerator<any, void, undefined> {
311311
yield * this.contentFetching.put(key, value, options)
312312
}
313313

314314
/**
315315
* Get the value that corresponds to the passed key
316316
*/
317-
async * get (key: Uint8Array, options: QueryOptions = {}) { // eslint-disable-line require-await
317+
async * get (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
318318
yield * this.contentFetching.get(key, options)
319319
}
320320

@@ -323,14 +323,14 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
323323
/**
324324
* Announce to the network that we can provide given key's value
325325
*/
326-
async * provide (key: CID, options: QueryOptions = {}) { // eslint-disable-line require-await
326+
async * provide (key: CID, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
327327
yield * this.contentRouting.provide(key, this.components.addressManager.getAddresses(), options)
328328
}
329329

330330
/**
331331
* Search the dht for providers of the given CID
332332
*/
333-
async * findProviders (key: CID, options: QueryOptions = {}) {
333+
async * findProviders (key: CID, options: QueryOptions = {}): AsyncGenerator<QueryEvent, any, unknown> {
334334
yield * this.contentRouting.findProviders(key, options)
335335
}
336336

@@ -339,18 +339,18 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
339339
/**
340340
* Search for a peer with the given ID
341341
*/
342-
async * findPeer (id: PeerId, options: QueryOptions = {}) { // eslint-disable-line require-await
342+
async * findPeer (id: PeerId, options: QueryOptions = {}): AsyncGenerator<QueryEvent, any, unknown> {
343343
yield * this.peerRouting.findPeer(id, options)
344344
}
345345

346346
/**
347347
* Kademlia 'node lookup' operation
348348
*/
349-
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}) {
349+
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent, any, unknown> {
350350
yield * this.peerRouting.getClosestPeers(key, options)
351351
}
352352

353-
async refreshRoutingTable () {
354-
await this.routingTableRefresh.refreshTable(true)
353+
async refreshRoutingTable (): Promise<void> {
354+
this.routingTableRefresh.refreshTable(true)
355355
}
356356
}

0 commit comments

Comments
 (0)