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

Commit

Permalink
deps(dev): bump aegir from 37.12.1 to 38.1.6 (#66)
Browse files Browse the repository at this point in the history
* deps(dev): bump aegir from 37.12.1 to 38.1.6

Bumps [aegir](https://github.com/ipfs/aegir) from 37.12.1 to 38.1.6.
- [Release notes](https://github.com/ipfs/aegir/releases)
- [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md)
- [Commits](ipfs/aegir@v37.12.1...v38.1.6)

---
updated-dependencies:
- dependency-name: aegir
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: fix linting and deps

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Potsides <alex@achingbrain.net>
  • Loading branch information
dependabot[bot] and achingbrain committed Mar 2, 2023
1 parent aa8fc54 commit df47658
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 48 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"dep-check": "aegir dep-check -i protons",
"generate": "protons src/pb/peer.proto src/pb/tags.proto",
"build": "aegir build",
"test": "aegir test",
Expand Down Expand Up @@ -166,10 +166,9 @@
"uint8arrays": "^4.0.2"
},
"devDependencies": {
"@libp2p/interface-compliance-tests": "^3.0.2",
"@libp2p/peer-id-factory": "^2.0.0",
"@libp2p/utils": "^3.0.2",
"aegir": "^37.9.1",
"aegir": "^38.1.6",
"datastore-core": "^8.0.1",
"delay": "^5.0.0",
"p-defer": "^4.0.0",
Expand Down
20 changes: 10 additions & 10 deletions src/address-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import map from 'it-map'
import each from 'it-foreach'
import { peerIdFromPeerId } from '@libp2p/peer-id'
import { CustomEvent } from '@libp2p/interfaces/events'
import type { AddressFilter, Peer, PeerMultiaddrsChangeData, PeerStore } from '@libp2p/interface-peer-store'
import type { Address, AddressFilter, Peer, PeerMultiaddrsChangeData, PeerStore } from '@libp2p/interface-peer-store'
import type { Store } from './store.js'
import type { Envelope } from '@libp2p/interface-record'
import type { PeerId } from '@libp2p/interface-peer-id'
Expand All @@ -20,7 +20,7 @@ import type { Multiaddr } from '@multiformats/multiaddr'
const log = logger('libp2p:peer-store:address-book')
const EVENT_NAME = 'change:multiaddrs'

async function allowAll () {
async function allowAll (): Promise<boolean> {
return true
}

Expand All @@ -40,7 +40,7 @@ export class PeerStoreAddressBook {
* This will return a boolean that indicates if the record was successfully processed and added
* into the AddressBook.
*/
async consumePeerRecord (envelope: Envelope) {
async consumePeerRecord (envelope: Envelope): Promise<boolean> {
log.trace('consumePeerRecord await write lock')
const release = await this.store.lock.writeLock()
log.trace('consumePeerRecord got write lock')
Expand Down Expand Up @@ -113,7 +113,7 @@ export class PeerStoreAddressBook {
return true
}

async getRawEnvelope (peerId: PeerId) {
async getRawEnvelope (peerId: PeerId): Promise<Uint8Array | undefined> {
log.trace('getRawEnvelope await read lock')
const release = await this.store.lock.readLock()
log.trace('getRawEnvelope got read lock')
Expand All @@ -136,7 +136,7 @@ export class PeerStoreAddressBook {
* Get an Envelope containing a PeerRecord for the given peer.
* Returns undefined if no record exists.
*/
async getPeerRecord (peerId: PeerId) {
async getPeerRecord (peerId: PeerId): Promise<RecordEnvelope | undefined> {
const raw = await this.getRawEnvelope(peerId)

if (raw == null) {
Expand All @@ -146,7 +146,7 @@ export class PeerStoreAddressBook {
return await RecordEnvelope.createFromProtobuf(raw)
}

async get (peerId: PeerId) {
async get (peerId: PeerId): Promise<Address[]> {
peerId = peerIdFromPeerId(peerId)

log.trace('get wait for read lock')
Expand All @@ -169,7 +169,7 @@ export class PeerStoreAddressBook {
return []
}

async set (peerId: PeerId, multiaddrs: Multiaddr[]) {
async set (peerId: PeerId, multiaddrs: Multiaddr[]): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!Array.isArray(multiaddrs)) {
Expand Down Expand Up @@ -239,7 +239,7 @@ export class PeerStoreAddressBook {
}
}

async add (peerId: PeerId, multiaddrs: Multiaddr[]) {
async add (peerId: PeerId, multiaddrs: Multiaddr[]): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!Array.isArray(multiaddrs)) {
Expand Down Expand Up @@ -307,7 +307,7 @@ export class PeerStoreAddressBook {
}
}

async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
peerId = peerIdFromPeerId(peerId)

log.trace('delete await write lock')
Expand Down Expand Up @@ -345,7 +345,7 @@ export class PeerStoreAddressBook {
}
}

async function filterMultiaddrs (peerId: PeerId, multiaddrs: Multiaddr[], addressFilter: AddressFilter, isCertified: boolean = false) {
async function filterMultiaddrs (peerId: PeerId, multiaddrs: Multiaddr[], addressFilter: AddressFilter, isCertified: boolean = false): Promise<Address[]> {
return await pipe(
multiaddrs,
(source) => each(source, (multiaddr) => {
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
this.protoBook = new PeerStoreProtoBook(this.dispatchEvent.bind(this), this.store)
}

async forEach (fn: (peer: Peer) => void) {
async forEach (fn: (peer: Peer) => void): Promise<void> {
log.trace('getPeers await read lock')
const release = await this.store.lock.readLock()
log.trace('getPeers got read lock')
Expand Down Expand Up @@ -74,7 +74,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
/**
* Delete the information of the given peer in every book
*/
async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
log.trace('delete await write lock')
const release = await this.store.lock.writeLock()
log.trace('delete got write lock')
Expand All @@ -90,7 +90,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
/**
* Get the stored information of a given peer
*/
async get (peerId: PeerId) {
async get (peerId: PeerId): Promise<Peer> {
log.trace('get await read lock')
const release = await this.store.lock.readLock()
log.trace('get got read lock')
Expand All @@ -106,7 +106,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
/**
* Returns true if we have a record of the peer
*/
async has (peerId: PeerId) {
async has (peerId: PeerId): Promise<boolean> {
log.trace('has await read lock')
const release = await this.store.lock.readLock()
log.trace('has got read lock')
Expand All @@ -119,7 +119,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
}
}

async tagPeer (peerId: PeerId, tag: string, options: TagOptions = {}) {
async tagPeer (peerId: PeerId, tag: string, options: TagOptions = {}): Promise<void> {
const providedValue = options.value ?? 0
const value = Math.round(providedValue)
const ttl = options.ttl ?? undefined
Expand Down Expand Up @@ -147,7 +147,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
await this.metadataBook.setValue(peerId, 'tags', Tags.encode({ tags }).subarray())
}

async unTagPeer (peerId: PeerId, tag: string) {
async unTagPeer (peerId: PeerId, tag: string): Promise<void> {
const buf = await this.metadataBook.getValue(peerId, 'tags')
let tags: Tag[] = []

Expand All @@ -160,7 +160,7 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
await this.metadataBook.setValue(peerId, 'tags', Tags.encode({ tags }).subarray())
}

async getTags (peerId: PeerId) {
async getTags (peerId: PeerId): Promise<Array<{ name: string, value: number }>> {
const buf = await this.metadataBook.getValue(peerId, 'tags')
let tags: Tag[] = []

Expand Down
8 changes: 4 additions & 4 deletions src/key-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PeerStoreKeyBook implements KeyBook {
/**
* Set the Peer public key
*/
async set (peerId: PeerId, publicKey: Uint8Array) {
async set (peerId: PeerId, publicKey: Uint8Array): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!(publicKey instanceof Uint8Array)) {
Expand Down Expand Up @@ -68,7 +68,7 @@ export class PeerStoreKeyBook implements KeyBook {
this.dispatchEvent(new CustomEvent<PeerPublicKeyChangeData>(EVENT_NAME, {
detail: {
peerId,
publicKey: publicKey,
publicKey,
oldPublicKey: peer == null ? undefined : peer.pubKey
}
}))
Expand All @@ -78,7 +78,7 @@ export class PeerStoreKeyBook implements KeyBook {
/**
* Get Public key of the given PeerId, if stored
*/
async get (peerId: PeerId) {
async get (peerId: PeerId): Promise<Uint8Array | undefined> {
peerId = peerIdFromPeerId(peerId)

log.trace('get await write lock')
Expand All @@ -99,7 +99,7 @@ export class PeerStoreKeyBook implements KeyBook {
}
}

async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
peerId = peerIdFromPeerId(peerId)

log.trace('delete await write lock')
Expand Down
12 changes: 6 additions & 6 deletions src/metadata-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
/**
* Get the known data of a provided peer
*/
async get (peerId: PeerId) {
async get (peerId: PeerId): Promise<Map<string, Uint8Array>> {
peerId = peerIdFromPeerId(peerId)

log.trace('get await read lock')
Expand All @@ -54,7 +54,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
/**
* Get specific metadata value, if it exists
*/
async getValue (peerId: PeerId, key: string) {
async getValue (peerId: PeerId, key: string): Promise<Uint8Array | undefined> {
peerId = peerIdFromPeerId(peerId)

log.trace('getValue await read lock')
Expand All @@ -75,7 +75,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
}
}

async set (peerId: PeerId, metadata: Map<string, Uint8Array>) {
async set (peerId: PeerId, metadata: Map<string, Uint8Array>): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!(metadata instanceof Map)) {
Expand Down Expand Up @@ -118,7 +118,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
/**
* Set metadata key and value of a provided peer
*/
async setValue (peerId: PeerId, key: string, value: Uint8Array) {
async setValue (peerId: PeerId, key: string, value: Uint8Array): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (typeof key !== 'string' || !(value instanceof Uint8Array)) {
Expand Down Expand Up @@ -164,7 +164,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
}))
}

async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
peerId = peerIdFromPeerId(peerId)

log.trace('delete await write lock')
Expand Down Expand Up @@ -203,7 +203,7 @@ export class PeerStoreMetadataBook implements MetadataBook {
}
}

async deleteValue (peerId: PeerId, key: string) {
async deleteValue (peerId: PeerId, key: string): Promise<void> {
peerId = peerIdFromPeerId(peerId)

log.trace('deleteValue await write lock')
Expand Down
10 changes: 5 additions & 5 deletions src/proto-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class PeerStoreProtoBook implements ProtoBook {
this.store = store
}

async get (peerId: PeerId) {
async get (peerId: PeerId): Promise<string[]> {
log.trace('get wait for read lock')
const release = await this.store.lock.readLock()
log.trace('get got read lock')
Expand All @@ -45,7 +45,7 @@ export class PeerStoreProtoBook implements ProtoBook {
return []
}

async set (peerId: PeerId, protocols: string[]) {
async set (peerId: PeerId, protocols: string[]): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!Array.isArray(protocols)) {
Expand Down Expand Up @@ -94,7 +94,7 @@ export class PeerStoreProtoBook implements ProtoBook {
}))
}

async add (peerId: PeerId, protocols: string[]) {
async add (peerId: PeerId, protocols: string[]): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!Array.isArray(protocols)) {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class PeerStoreProtoBook implements ProtoBook {
}))
}

async remove (peerId: PeerId, protocols: string[]) {
async remove (peerId: PeerId, protocols: string[]): Promise<void> {
peerId = peerIdFromPeerId(peerId)

if (!Array.isArray(protocols)) {
Expand Down Expand Up @@ -196,7 +196,7 @@ export class PeerStoreProtoBook implements ProtoBook {
}))
}

async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
peerId = peerIdFromPeerId(peerId)

log.trace('delete await write lock')
Expand Down
22 changes: 11 additions & 11 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PersistentStore {
})
}

_peerIdToDatastoreKey (peerId: PeerId) {
_peerIdToDatastoreKey (peerId: PeerId): Key {
if (peerId.type == null) {
log.error('peerId must be an instance of peer-id to store data')
throw new CodeError('peerId must be an instance of peer-id', codes.ERR_INVALID_PARAMETERS)
Expand All @@ -55,11 +55,11 @@ export class PersistentStore {
return new Key(`${NAMESPACE_COMMON}${b32key}`)
}

async has (peerId: PeerId) {
async has (peerId: PeerId): Promise<boolean> {
return await this.components.datastore.has(this._peerIdToDatastoreKey(peerId))
}

async delete (peerId: PeerId) {
async delete (peerId: PeerId): Promise<void> {
await this.components.datastore.delete(this._peerIdToDatastoreKey(peerId))
}

Expand Down Expand Up @@ -87,7 +87,7 @@ export class PersistentStore {
}
}

async save (peer: Peer) {
async save (peer: Peer): Promise<Peer> {
if (peer.pubKey != null && peer.id.publicKey != null && !uint8arrayEquals(peer.pubKey, peer.id.publicKey)) {
log.error('peer publicKey bytes do not match peer id publicKey bytes')
throw new CodeError('publicKey bytes do not match peer id publicKey bytes', codes.ERR_INVALID_PARAMETERS)
Expand Down Expand Up @@ -135,13 +135,13 @@ export class PersistentStore {
return await this.load(peer.id)
}

async patch (peerId: PeerId, data: Partial<Peer>) {
async patch (peerId: PeerId, data: Partial<Peer>): Promise<Peer> {
const peer = await this.load(peerId)

return await this._patch(peerId, data, peer)
}

async patchOrCreate (peerId: PeerId, data: Partial<Peer>) {
async patchOrCreate (peerId: PeerId, data: Partial<Peer>): Promise<Peer> {
let peer: Peer

try {
Expand All @@ -157,21 +157,21 @@ export class PersistentStore {
return await this._patch(peerId, data, peer)
}

async _patch (peerId: PeerId, data: Partial<Peer>, peer: Peer) {
async _patch (peerId: PeerId, data: Partial<Peer>, peer: Peer): Promise<Peer> {
return await this.save({
...peer,
...data,
id: peerId
})
}

async merge (peerId: PeerId, data: Partial<Peer>) {
async merge (peerId: PeerId, data: Partial<Peer>): Promise<Peer> {
const peer = await this.load(peerId)

return await this._merge(peerId, data, peer)
}

async mergeOrCreate (peerId: PeerId, data: Partial<Peer>) {
async mergeOrCreate (peerId: PeerId, data: Partial<Peer>): Promise<Peer> {
/** @type {Peer} */
let peer

Expand All @@ -188,7 +188,7 @@ export class PersistentStore {
return await this._merge(peerId, data, peer)
}

async _merge (peerId: PeerId, data: Partial<Peer>, peer: Peer) {
async _merge (peerId: PeerId, data: Partial<Peer>, peer: Peer): Promise<Peer> {
// if the peer has certified addresses, use those in
// favour of the supplied versions
const addresses = new Map<string, boolean>()
Expand Down Expand Up @@ -227,7 +227,7 @@ export class PersistentStore {
})
}

async * all () {
async * all (): AsyncGenerator<Peer, void, unknown> {
for await (const key of this.components.datastore.queryKeys({
prefix: NAMESPACE_COMMON
})) {
Expand Down
Loading

0 comments on commit df47658

Please sign in to comment.