Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
feat: replace protocol-buffers with protons (#42)
Browse files Browse the repository at this point in the history
* feat: replace protocol-buffers with protons

Ref ipfs/js-ipfs#991

* feat: upgrade to aegir@12
  • Loading branch information
dignifiedquire authored and daviddias committed Sep 7, 2017
1 parent 52fdf7b commit 4ac25c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ test/test-data/go-ipfs-repo/LOG.old

# while testing npm5
package-lock.json
yarn.lock
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ matrix:
script:
- npm run lint
- npm run test
- npm run coverage
- make test
- npm run coverage -- --upload

before_script:
- export DISPLAY=:99.0
Expand Down
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"description": "libp2p Identify Protocol",
"main": "src/index.js",
"scripts": {
"lint": "aegir-lint",
"build": "aegir-build",
"test": "aegir-test",
"test:node": "aegir-test --env node",
"test:browser": "aegir-test --env browser",
"release": "aegir-release",
"release-minor": "aegir-release --type minor",
"release-major": "aegir-release --type major",
"coverage": "aegir-coverage",
"coverage-publish": "aegir-coverage publish"
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage"
},
"pre-commit": [
"lint",
Expand All @@ -38,17 +37,17 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
"devDependencies": {
"aegir": "^11.0.2",
"aegir": "^12.0.6",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"pre-commit": "^1.2.2",
"pull-pair": "^1.1.0"
},
"dependencies": {
"multiaddr": "^3.0.0",
"multiaddr": "^3.0.1",
"peer-id": "~0.10.0",
"peer-info": "~0.11.0",
"protocol-buffers": "^3.2.1",
"protons": "^1.0.0",
"pull-length-prefixed": "^1.3.0",
"pull-stream": "^3.6.0"
},
Expand All @@ -58,4 +57,4 @@
"Greenkeeper <[email protected]>",
"Richard Littauer <[email protected]>"
]
}
}
4 changes: 2 additions & 2 deletions src/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (conn, pInfoSelf) => {
if (err) { return }
observedAddrs = observedAddrs[0]

let publicKey = new Buffer(0)
let publicKey = Buffer.alloc(0)
if (pInfoSelf.id.pubKey) {
publicKey = pInfoSelf.id.pubKey.bytes
}
Expand All @@ -21,7 +21,7 @@ module.exports = (conn, pInfoSelf) => {
agentVersion: 'na',
publicKey: publicKey,
listenAddrs: pInfoSelf.multiaddrs.toArray().map((ma) => ma.buffer),
observedAddr: observedAddrs ? observedAddrs.buffer : new Buffer('')
observedAddr: observedAddrs ? observedAddrs.buffer : Buffer.from('')
})

pull(
Expand Down
8 changes: 4 additions & 4 deletions src/message.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const protobuf = require('protocol-buffers')
const schema = new Buffer(`
const protons = require('protons')
const schema = `
message Identify {
// protocolVersion determines compatibility between peers
optional string protocolVersion = 5; // e.g. ipfs/1.0.0
Expand All @@ -25,6 +25,6 @@ message Identify {
repeated string protocols = 3;
}
`)
`

module.exports = protobuf(schema).Identify
module.exports = protons(schema).Identify

0 comments on commit 4ac25c9

Please sign in to comment.