Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"docs:no-publish": "aegir docs --publish false"
},
"dependencies": {
"aegir": "^42.2.3",
"aegir": "^44.1.0",
"npm-run-all": "^4.1.5"
},
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@libp2p/daemon-server": "^7.0.0",
"@libp2p/interface-compliance-tests": "^5.2.0",
"@libp2p/kad-dht": "^12.0.5",
"aegir": "^42.2.3",
"aegir": "^44.1.0",
"it-all": "^3.0.4",
"it-pipe": "^3.0.1",
"sinon": "^18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/libp2p-daemon-client/src/dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class DHT {
throw new CodeError(response.error?.msg ?? 'DHT get failed', 'ERR_DHT_GET_FAILED')
}

if (response.dht == null || response.dht.value == null) {
if (response.dht?.value == null) {
throw new CodeError('Invalid DHT get response', 'ERR_DHT_GET_FAILED')
}

Expand Down Expand Up @@ -108,7 +108,7 @@ export class DHT {
throw new CodeError(response.error?.msg ?? 'DHT find peer failed', 'ERR_DHT_FIND_PEER_FAILED')
}

if (response.dht == null || response.dht.peer == null || response.dht.peer.addrs == null) {
if (response.dht?.peer?.addrs == null) {
throw new CodeError('Invalid response', 'ERR_DHT_FIND_PEER_FAILED')
}

Expand Down Expand Up @@ -178,7 +178,7 @@ export class DHT {
}

// Stream values
if (dhtResponse.type === DHTResponse.Type.VALUE && dhtResponse.peer != null && dhtResponse.peer?.addrs != null) {
if (dhtResponse.type === DHTResponse.Type.VALUE && dhtResponse.peer?.addrs != null) {
yield {
id: peerIdFromBytes(dhtResponse.peer.id),
multiaddrs: dhtResponse.peer.addrs.map((a) => multiaddr(a))
Expand Down
5 changes: 4 additions & 1 deletion packages/libp2p-daemon-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Client implements DaemonClient {
throw new CodeError(response.error?.msg ?? 'Identify failed', 'ERR_IDENTIFY_FAILED')
}

if (response.identify == null || response.identify.addrs == null) {
if (response.identify?.addrs == null) {
throw new CodeError('Invalid response', 'ERR_IDENTIFY_FAILED')
}

Expand Down Expand Up @@ -211,6 +211,9 @@ class Client implements DaemonClient {
// @ts-expect-error because we are using a passthrough upgrader, this is a MultiaddrConnection
await handler(sh.rest())
})
.catch(err => {
connection.abort(err)
})
.finally(() => {
connection.close()
.catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions packages/libp2p-daemon-client/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Pubsub {
throw new CodeError(response.error?.msg ?? 'Pubsub get topics failed', 'ERR_PUBSUB_GET_TOPICS_FAILED')
}

if (response.pubsub == null || response.pubsub.topics == null) {
if (response.pubsub?.topics == null) {
throw new CodeError('Invalid response', 'ERR_PUBSUB_GET_TOPICS_FAILED')
}

Expand Down Expand Up @@ -134,7 +134,7 @@ export class Pubsub {
throw new CodeError(response.error?.msg ?? 'Pubsub get subscribers failed', 'ERR_PUBSUB_GET_SUBSCRIBERS_FAILED')
}

if (response.pubsub == null || response.pubsub.topics == null) {
if (response.pubsub?.topics == null) {
throw new CodeError('Invalid response', 'ERR_PUBSUB_GET_SUBSCRIBERS_FAILED')
}

Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"uint8arraylist": "^2.4.8"
},
"devDependencies": {
"aegir": "^42.2.3",
"aegir": "^44.1.0",
"protons": "^7.5.0"
}
}
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"uint8arrays": "^5.0.1"
},
"devDependencies": {
"aegir": "^42.2.3",
"aegir": "^44.1.0",
"sinon-ts": "^2.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/libp2p-daemon-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Server implements Libp2pServer {
* Connects the daemons libp2p node to the peer provided
*/
async connect (request: Request): Promise<Connection> {
if (request.connect == null || request.connect.addrs == null) {
if (request.connect?.addrs == null) {
throw new Error('Invalid request')
}

Expand All @@ -102,7 +102,7 @@ export class Server implements Libp2pServer {
* Opens a stream on one of the given protocols to the given peer
*/
async openStream (request: Request): Promise<OpenStream> {
if (request.streamOpen == null || request.streamOpen.proto == null) {
if (request.streamOpen?.proto == null) {
throw new Error('Invalid request')
}

Expand Down Expand Up @@ -135,7 +135,7 @@ export class Server implements Libp2pServer {
* is registered at the path, it will be overridden.
*/
async registerStreamHandler (request: Request): Promise<void> {
if (request.streamHandler == null || request.streamHandler.proto == null) {
if (request.streamHandler?.proto == null) {
throw new Error('Invalid request')
}

Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"yargs-promise": "^1.1.0"
},
"devDependencies": {
"aegir": "^42.2.3",
"aegir": "^44.1.0",
"sinon": "^18.0.0"
}
}