Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: bump protons-runtime from 4.0.2 to 5.0.0 #72

Merged
merged 7 commits into from
Mar 28, 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [8.0.2](https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/compare/v8.0.1...v8.0.2) (2023-03-21)


### Dependencies

* bump @multiformats/multiaddr from 11.6.1 to 12.0.0 ([#87](https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/issues/87)) ([31ce222](https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/commit/31ce2224a6d060517f1b6ce7677a625af6b5eb78))

## [8.0.1](https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/compare/v8.0.0...v8.0.1) (2023-03-20)


Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libp2p/pubsub-peer-discovery",
"version": "8.0.1",
"version": "8.0.2",
"description": "A libp2p module that uses pubsub for mdns like peer discovery",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p-pubsub-peer-discovery#readme",
Expand Down Expand Up @@ -133,7 +133,7 @@
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"dep-check": "aegir dep-check -i protons",
"build": "aegir build",
"generate": "protons ./src/peer.proto",
"test": "aegir test",
Expand All @@ -152,13 +152,14 @@
"@libp2p/logger": "^2.0.1",
"@libp2p/peer-id": "^2.0.0",
"@multiformats/multiaddr": "^12.0.0",
"protons-runtime": "^4.0.1"
"protons-runtime": "^5.0.0",
"uint8arraylist": "^2.4.3"
},
"devDependencies": {
"@libp2p/interface-address-manager": "^2.0.0",
"@libp2p/interface-peer-discovery-compliance-tests": "^2.0.0",
"@libp2p/peer-id-factory": "^2.0.0",
"aegir": "^37.9.1",
"aegir": "^38.1.8",
"p-defer": "^4.0.0",
"p-wait-for": "^5.0.0",
"protons": "^7.0.2",
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ export class PubSubPeerDiscovery extends EventEmitter<PeerDiscoveryEvents> imple
return true
}

get [Symbol.toStringTag] () {
get [Symbol.toStringTag] (): '@libp2p/pubsub-peer-discovery' {
return '@libp2p/pubsub-peer-discovery'
}

isStarted () {
isStarted (): boolean {
return this.intervalId != null
}

start () {
start (): void {

}

/**
* Subscribes to the discovery topic on `libp2p.pubsub` and performs a broadcast
* immediately, and every `this.interval`
*/
afterStart () {
afterStart (): void {
if (this.intervalId != null) {
return
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export class PubSubPeerDiscovery extends EventEmitter<PeerDiscoveryEvents> imple
}, this.interval)
}

beforeStop () {
beforeStop (): void {
const pubsub = this.components.pubsub

if (pubsub == null) {
Expand All @@ -137,7 +137,7 @@ export class PubSubPeerDiscovery extends EventEmitter<PeerDiscoveryEvents> imple
/**
* Unsubscribes from the discovery topic
*/
stop () {
stop (): void {
if (this.intervalId != null) {
clearInterval(this.intervalId)
this.intervalId = undefined
Expand All @@ -147,7 +147,7 @@ export class PubSubPeerDiscovery extends EventEmitter<PeerDiscoveryEvents> imple
/**
* Performs a broadcast via Pubsub publish
*/
_broadcast () {
_broadcast (): void {
const peerId = this.components.peerId

if (peerId.publicKey == null) {
Expand Down Expand Up @@ -175,7 +175,7 @@ export class PubSubPeerDiscovery extends EventEmitter<PeerDiscoveryEvents> imple
/**
* Handles incoming pubsub messages for our discovery topic
*/
_onMessage (event: CustomEvent<Message>) {
_onMessage (event: CustomEvent<Message>): void {
if (!this.isStarted()) {
return
}
Expand Down
7 changes: 4 additions & 3 deletions src/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */

import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

export interface Peer {
publicKey: Uint8Array
Expand All @@ -22,7 +23,7 @@ export namespace Peer {
w.fork()
}

if (opts.writeDefaults === true || (obj.publicKey != null && obj.publicKey.byteLength > 0)) {
if ((obj.publicKey != null && obj.publicKey.byteLength > 0)) {
w.uint32(10)
w.bytes(obj.publicKey)
}
Expand Down Expand Up @@ -68,7 +69,7 @@ export namespace Peer {
return _codec
}

export const encode = (obj: Peer): Uint8Array => {
export const encode = (obj: Partial<Peer>): Uint8Array => {
return encodeMessage(obj, Peer.codec())
}

Expand Down
2 changes: 1 addition & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('PubSub Peer Discovery', () => {
discovery = pubsubPeerDiscovery()(components)
await start(discovery)

const handler = () => {}
const handler = (): void => {}
discovery.addEventListener('peer', handler)
expect(discovery.listenerCount('peer')).to.equal(1)
discovery.removeEventListener('peer', handler)
Expand Down