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

fix: switch to protobufjs #39

Merged
merged 3 commits into from
Sep 5, 2017
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/dag.proto.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ test/repo-just-for-test*

# Vim .swp files
**.swp

package-lock.json
yarn.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing to .gitignore the generated file.

10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ sudo: false
language: node_js
matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8
- node_js: 8
env: CXX=g++-4.8

# Make sure we have new NPM.
Expand All @@ -33,4 +29,4 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-4.8
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"lint": "aegir-lint",
"build": "aegir-build",
"build-proto": "pbjs --wrap commonjs --target static-module src/dag.proto > src/dag.proto.js",
"test": "aegir-test",
"test:node": "aegir-test node",
"test:browser": "aegir-test browser",
Expand Down Expand Up @@ -52,7 +53,7 @@
"is-ipfs": "~0.3.0",
"multihashes": "~0.4.4",
"multihashing-async": "~0.4.4",
"protocol-buffers": "^3.2.1",
"protobufjs": "^6.8.0",
"pull-stream": "^3.5.0",
"pull-traverse": "^1.0.3",
"stable": "^0.1.6"
Expand All @@ -70,4 +71,4 @@
"pre-commit": "^1.2.2",
"rimraf": "^2.6.1"
}
}
}
4 changes: 2 additions & 2 deletions src/dag-node/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function create (data, dagLinks, hashAlg, callback) {
callback = data
data = undefined
} else if (typeof data === 'string') {
data = new Buffer(data)
data = Buffer.from(data)
}
if (typeof dagLinks === 'function') {
callback = dagLinks
Expand All @@ -26,7 +26,7 @@ function create (data, dagLinks, hashAlg, callback) {
}

if (!Buffer.isBuffer(data)) {
return callback('Passed \'data\' is not a buffer or a string!')
return callback(new Error('Passed \'data\' is not a buffer or a string!'))
}

if (!hashAlg) {
Expand Down
2 changes: 1 addition & 1 deletion src/dag-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DAGNode {
multihash = mh.fromB58String(multihash)
}

this._data = data || new Buffer(0)
this._data = data || Buffer.alloc(0)
this._links = links || []
this._serialized = serialized
this._multihash = multihash
Expand Down
22 changes: 22 additions & 0 deletions src/dag.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// An IPFS MerkleDAG Link
message PBLink {

// multihash of the target object
optional bytes Hash = 1;

// utf string name. should be unique per object
optional string Name = 2;

// cumulative size of target object
optional uint64 Tsize = 3;
}

// An IPFS MerkleDAG Node
message PBNode {

// refs to other objects
repeated PBLink Links = 2;

// opaque user data
optional bytes Data = 1;
}
Loading