Skip to content

Commit

Permalink
fix: remove protobufjs and replace with protons (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Apr 7, 2022
1 parent 8c6e03a commit 78dd02a
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 6,013 deletions.
10 changes: 5 additions & 5 deletions packages/libp2p-daemon-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import errcode from 'err-code'
import { TCP } from '@libp2p/tcp'
import { IRequest, PSMessage, Request, Response } from '@libp2p/daemon-protocol'
import { PSMessage, Request, Response } from '@libp2p/daemon-protocol'
import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler'
import { Multiaddr } from '@multiformats/multiaddr'
import { DHT } from './dht.js'
Expand Down Expand Up @@ -43,11 +43,11 @@ class Client implements DaemonClient {
* Sends the request to the daemon and returns a stream. This
* should only be used when sending daemon requests.
*/
async send (request: IRequest) {
async send (request: Request) {
const maConn = await this.connectDaemon()

const streamHandler = new StreamHandler({ stream: maConn })
streamHandler.write(Request.encode(request).finish())
streamHandler.write(Request.encode(request))
return streamHandler
}

Expand Down Expand Up @@ -189,7 +189,7 @@ class Client implements DaemonClient {

const sh = await this.send({
type: Request.Type.STREAM_HANDLER,
streamOpen: null,
streamOpen: undefined,
streamHandler: {
addr: addr.bytes,
proto: [protocol]
Expand Down Expand Up @@ -234,7 +234,7 @@ export interface DaemonClient {
dht: DHTClient
pubsub: PubSubClient

send: (request: IRequest) => Promise<StreamHandler>
send: (request: Request) => Promise<StreamHandler>
openStream: (peerId: PeerId, protocol: string) => Promise<Duplex<Uint8Array>>
}

Expand Down
9 changes: 3 additions & 6 deletions packages/libp2p-daemon-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,13 @@
"clean": "aegir clean",
"lint": "aegir lint",
"build": "aegir build",
"postbuild": "cp src/*.js src/*.d.ts dist/src",
"generate": "npm run generate:proto && npm run generate:proto-types",
"generate:proto": "pbjs -t static-module -w es6 -r libp2p-daemon --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/protocol/index.js ./src/protocol/index.proto",
"generate:proto-types": "pbts -o src/protocol/index.d.ts src/protocol/index.js",
"release": "aegir release"
},
"dependencies": {
"protobufjs": "^6.10.2"
"protons-runtime": "^1.0.0"
},
"devDependencies": {
"aegir": "^37.0.5"
"aegir": "^37.0.5",
"protons": "^3.0.1"
}
}
Loading

0 comments on commit 78dd02a

Please sign in to comment.