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

deps(dev): bump aegir from 37.12.1 to 38.1.7 #427

Merged
merged 6 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"dep-check": "aegir dep-check",
"dep-check": "aegir dep-check -i protons",
"release": "aegir release",
"docs": "aegir docs"
},
Expand All @@ -163,7 +163,6 @@
"abortable-iterator": "^4.0.2",
"any-signal": "^3.0.0",
"datastore-core": "^8.0.1",
"events": "^3.3.0",
"hashlru": "^2.3.0",
"interface-datastore": "^7.0.0",
"it-all": "^2.0.0",
Expand Down Expand Up @@ -196,13 +195,12 @@
"@types/lodash.range": "^3.2.6",
"@types/varint": "^6.0.0",
"@types/which": "^2.0.1",
"aegir": "^37.7.7",
"aegir": "^38.1.2",
"datastore-level": "^9.0.0",
"delay": "^5.0.0",
"execa": "^6.0.0",
"it-filter": "^2.0.0",
"it-last": "^2.0.0",
"it-pair": "^2.0.2",
"lodash.random": "^3.2.0",
"lodash.range": "^3.2.0",
"p-retry": "^5.0.0",
Expand Down
18 changes: 9 additions & 9 deletions src/content-fetching/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../constants.js'
import { createPutRecord, convertBuffer, bufferToRecordKey } from '../utils.js'
import { logger } from '@libp2p/logger'
import type { Validators, Selectors, ValueEvent, QueryOptions } from '@libp2p/interface-dht'
import type { Validators, Selectors, ValueEvent, QueryOptions, QueryEvent } from '@libp2p/interface-dht'
import type { PeerRouting } from '../peer-routing/index.js'
import type { QueryManager } from '../query/manager.js'
import type { RoutingTable } from '../routing-table/index.js'
Expand Down Expand Up @@ -59,7 +59,7 @@ export class ContentFetching {
this.network = network
}

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

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

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

// create record in the dht format
const record = await createPutRecord(key, value)
const record = createPutRecord(key, value)

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

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

try {
Expand Down
8 changes: 4 additions & 4 deletions src/content-routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
providerEvent
} from '../query/events.js'
import { logger } from '@libp2p/logger'
import type { QueryEvent, QueryOptions } from '@libp2p/interface-dht'
import type { PeerResponseEvent, ProviderEvent, QueryEvent, QueryOptions } from '@libp2p/interface-dht'
import type { PeerRouting } from '../peer-routing/index.js'
import type { QueryManager } from '../query/manager.js'
import type { RoutingTable } from '../routing-table/index.js'
Expand Down Expand Up @@ -58,7 +58,7 @@ export class ContentRouting {
* Announce to the network that we can provide the value for a given key and
* are contactable on the given multiaddrs
*/
async * provide (key: CID, multiaddrs: Multiaddr[], options: AbortOptions = {}) {
async * provide (key: CID, multiaddrs: Multiaddr[], options: AbortOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
this.log('provide %s', key)

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

yield peerResponseEvent({ from: this.components.peerId, messageType: MESSAGE_TYPE.GET_PROVIDERS, providers })
yield providerEvent({ from: this.components.peerId, providers: providers })
yield providerEvent({ from: this.components.peerId, providers })
}

// All done
Expand Down
28 changes: 14 additions & 14 deletions src/dual-kad-dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CodeError } from '@libp2p/interfaces/errors'
import merge from 'it-merge'
import { queryErrorEvent } from './query/events.js'
import type { KadDHT } from './kad-dht.js'
import type { DualDHT, QueryOptions } from '@libp2p/interface-dht'
import type { DualDHT, QueryEvent, QueryOptions } from '@libp2p/interface-dht'
import type { AbortOptions } from '@libp2p/interfaces'
import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
import type { CID } from 'multiformats'
Expand Down Expand Up @@ -47,35 +47,35 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
return true
}

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

/**
* Is this DHT running.
*/
isStarted () {
isStarted (): boolean {
return this.wan.isStarted() && this.lan.isStarted()
}

/**
* If 'server' this node will respond to DHT queries, if 'client' this node will not
*/
async getMode () {
async getMode (): Promise<'client' | 'server'> {
return await this.wan.getMode()
}

/**
* If 'server' this node will respond to DHT queries, if 'client' this node will not
*/
async setMode (mode: 'client' | 'server') {
async setMode (mode: 'client' | 'server'): Promise<void> {
await this.wan.setMode(mode)
}

/**
* Start listening to incoming connections.
*/
async start () {
async start (): Promise<void> {
await Promise.all([
this.lan.start(),
this.wan.start()
Expand All @@ -86,7 +86,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
* Stop accepting incoming connections and sending outgoing
* messages.
*/
async stop () {
async stop (): Promise<void> {
await Promise.all([
this.lan.stop(),
this.wan.stop()
Expand All @@ -96,7 +96,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Store the given key/value pair in the DHT
*/
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}) {
async * put (key: Uint8Array, value: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
for await (const event of merge(
this.lan.put(key, value, options),
this.wan.put(key, value, options)
Expand All @@ -108,7 +108,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Get the value that corresponds to the passed key
*/
async * get (key: Uint8Array, options: QueryOptions = {}) { // eslint-disable-line require-await
async * get (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
let queriedPeers = false
let foundValue = false

Expand Down Expand Up @@ -152,7 +152,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Announce to the network that we can provide given key's value
*/
async * provide (key: CID, options: AbortOptions = {}) { // eslint-disable-line require-await
async * provide (key: CID, options: AbortOptions = {}): AsyncGenerator<QueryEvent> {
let sent = 0
let success = 0
const errors = []
Expand Down Expand Up @@ -194,7 +194,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Search the dht for up to `K` providers of the given CID
*/
async * findProviders (key: CID, options: QueryOptions = {}) {
async * findProviders (key: CID, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
yield * merge(
this.lan.findProviders(key, options),
this.wan.findProviders(key, options)
Expand All @@ -206,7 +206,7 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Search for a peer with the given ID
*/
async * findPeer (id: PeerId, options: QueryOptions = {}) {
async * findPeer (id: PeerId, options: QueryOptions = {}): AsyncGenerator<QueryEvent> {
let queriedPeers = false

for await (const event of merge(
Expand All @@ -228,14 +228,14 @@ export class DualKadDHT extends EventEmitter<PeerDiscoveryEvents> implements Dua
/**
* Kademlia 'node lookup' operation
*/
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}) {
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent, void, undefined> {
yield * merge(
this.lan.getClosestPeers(key, options),
this.wan.getClosestPeers(key, options)
)
}

async refreshRoutingTable () {
async refreshRoutingTable (): Promise<void> {
await Promise.all([
this.lan.refreshRoutingTable(),
this.wan.refreshRoutingTable()
Expand Down
32 changes: 16 additions & 16 deletions src/kad-dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
removePublicAddresses
} from './utils.js'
import { Logger, logger } from '@libp2p/logger'
import type { QueryOptions, Validators, Selectors, DHT } from '@libp2p/interface-dht'
import type { QueryOptions, Validators, Selectors, DHT, QueryEvent } from '@libp2p/interface-dht'
import type { PeerInfo } from '@libp2p/interface-peer-info'
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
import type { PeerId } from '@libp2p/interface-peer-id'
Expand Down Expand Up @@ -207,11 +207,11 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
return true
}

get [Symbol.toStringTag] () {
get [Symbol.toStringTag] (): '@libp2p/kad-dht' {
return '@libp2p/kad-dht'
}

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

if (this.lan) {
Expand All @@ -235,21 +235,21 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT {
/**
* Is this DHT running.
*/
isStarted () {
isStarted (): boolean {
return this.running
}

/**
* If 'server' this node will respond to DHT queries, if 'client' this node will not
*/
async getMode () {
async getMode (): Promise<'client' | 'server'> {
return this.clientMode ? 'client' : 'server'
}

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

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

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

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

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

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

/**
* Search the dht for providers of the given CID
*/
async * findProviders (key: CID, options: QueryOptions = {}) {
async * findProviders (key: CID, options: QueryOptions = {}): AsyncGenerator<QueryEvent, any, unknown> {
yield * this.contentRouting.findProviders(key, options)
}

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

/**
* Kademlia 'node lookup' operation
*/
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}) {
async * getClosestPeers (key: Uint8Array, options: QueryOptions = {}): AsyncGenerator<QueryEvent, any, unknown> {
yield * this.peerRouting.getClosestPeers(key, options)
}

async refreshRoutingTable () {
await this.routingTableRefresh.refreshTable(true)
async refreshRoutingTable (): Promise<void> {
this.routingTableRefresh.refreshTable(true)
}
}
Loading