Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ea8e459

Browse files
author
Alan Shaw
authored
Merge branch 'master' into chore/interface-tests-async-node-creation
2 parents c9a63ed + b276372 commit ea8e459

File tree

15 files changed

+178
-48
lines changed

15 files changed

+178
-48
lines changed

COPYRIGHT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license.
2+
Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by
3+
a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is
4+
licensed under MIT-only. All new contributions (and past contributions since 2019-11-21)
5+
are licensed under a dual MIT/Apache-2.0 license.

LICENSE-APACHE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

LICENSE renamed to LICENSE-MIT

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Juan Batiz-Benet
4-
53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
75
in the Software without restriction, including without limitation the rights
@@ -18,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1816
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1917
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2018
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
19+
THE SOFTWARE.

docs/RELEASE_ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# ✅ Release Checklist
2222

2323
- [ ] **Stage 0 - Automated Testing**
24-
- [ ] Feature freeze. If any "non-trivial" changes (see the footnotes of [doc/releases.md](https://github.com/ipfs/js-ipfs/tree/master/doc/releases.md) for a definition) get added to the release, uncheck all the checkboxes and return to this stage.
24+
- [ ] Feature freeze. If any "non-trivial" changes (see the footnotes of [docs/releases.md](https://github.com/ipfs/js-ipfs/tree/master/docs/releases.md) for a definition) get added to the release, uncheck all the checkboxes and return to this stage.
2525
- [ ] Automated Testing (already tested in CI) - Ensure that all tests are passing, this includes:
2626
- [ ] unit/functional/integration/e2e
2727
- [ ] interop
@@ -71,11 +71,11 @@
7171
- Infrastructure Testing:
7272
- TBD
7373
- [ ] **Stage 2 - Community Dev Testing**
74-
- [ ] Reach out to the IPFS _early testers_ listed in [doc/EARLY_TESTERS.md](https://github.com/ipfs/js-ipfs/tree/master/doc/EARLY_TESTERS.md) for testing this release (check when no more problems have been reported). If you'd like to be added to this list, please file a PR.
74+
- [ ] Reach out to the IPFS _early testers_ listed in [docs/EARLY_TESTERS.md](https://github.com/ipfs/js-ipfs/tree/master/docs/EARLY_TESTERS.md) for testing this release (check when no more problems have been reported). If you'd like to be added to this list, please file a PR.
7575
- [ ] Reach out on IRC for additional early testers.
7676
- [ ] **Stage 3 - Community Prod Testing**
7777
- [ ] Update [js.ipfs.io](https://js.ipfs.io) examples to use the latest js-ipfs
78-
- [ ] Invite the IPFS [_early testers_](https://github.com/ipfs/js-ipfs/tree/master/doc/EARLY_TESTERS.md) to deploy the release to part of their production infrastructure.
78+
- [ ] Invite the IPFS [_early testers_](https://github.com/ipfs/js-ipfs/tree/master/docs/EARLY_TESTERS.md) to deploy the release to part of their production infrastructure.
7979
- [ ] Invite the wider community (link to the release issue):
8080
- [ ] [discuss.ipfs.io](https://discuss.ipfs.io/c/announcements)
8181
- [ ] Twitter

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"homepage": "https://js.ipfs.io",
99
"bugs": "https://github.com/ipfs/js-ipfs/issues",
10-
"license": "MIT",
10+
"license": "(Apache-2.0 OR MIT)",
1111
"leadMaintainer": "Alan Shaw <[email protected]>",
1212
"files": [
1313
"src",
@@ -78,10 +78,10 @@
7878
"buffer-peek-stream": "^1.0.1",
7979
"byteman": "^1.3.5",
8080
"callbackify": "^1.1.0",
81-
"cid-tool": "~0.3.0",
81+
"cid-tool": "~0.4.0",
8282
"cids": "~0.7.1",
8383
"class-is": "^1.1.0",
84-
"dag-cbor-links": "^1.3.0",
84+
"dag-cbor-links": "^1.3.2",
8585
"datastore-core": "~0.7.0",
8686
"datastore-pubsub": "^0.2.1",
8787
"debug": "^4.1.0",
@@ -100,9 +100,9 @@
100100
"ipfs-bitswap": "^0.26.0",
101101
"ipfs-block": "~0.8.1",
102102
"ipfs-block-service": "~0.16.0",
103-
"ipfs-http-client": "^39.0.2",
103+
"ipfs-http-client": "^40.0.1",
104104
"ipfs-http-response": "~0.4.0",
105-
"ipfs-mfs": "^0.13.0",
105+
"ipfs-mfs": "^0.13.2",
106106
"ipfs-multipart": "^0.2.0",
107107
"ipfs-repo": "^0.29.0",
108108
"ipfs-unixfs": "~0.1.16",
@@ -164,6 +164,7 @@
164164
"peer-book": "^0.9.1",
165165
"peer-id": "^0.12.2",
166166
"peer-info": "~0.15.1",
167+
"pretty-bytes": "^5.3.0",
167168
"progress": "^2.0.1",
168169
"promise-nodeify": "^3.0.1",
169170
"promisify-es6": "^1.0.3",
@@ -190,7 +191,7 @@
190191
"update-notifier": "^3.0.1",
191192
"uri-to-multiaddr": "^3.0.1",
192193
"varint": "^5.0.0",
193-
"yargs": "^14.0.0",
194+
"yargs": "^15.0.1",
194195
"yargs-promise": "^1.1.0"
195196
},
196197
"devDependencies": {

src/cli/commands/bitswap/stat.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const multibase = require('multibase')
44
const { cidToString } = require('../../../utils/cid')
5+
const prettyBytes = require('pretty-bytes')
56

67
module.exports = {
78
command: 'stat',
@@ -13,24 +14,42 @@ module.exports = {
1314
describe: 'Number base to display CIDs in. Note: specifying a CID base for v0 CIDs will have no effect.',
1415
type: 'string',
1516
choices: multibase.names
17+
},
18+
human: {
19+
type: 'boolean',
20+
default: false
1621
}
1722
},
1823

19-
handler ({ getIpfs, print, cidBase, resolve }) {
24+
handler ({ getIpfs, print, cidBase, resolve, human }) {
2025
resolve((async () => {
2126
const ipfs = await getIpfs()
2227
const stats = await ipfs.bitswap.stat()
23-
stats.wantlist = stats.wantlist.map(k => cidToString(k['/'], { base: cidBase, upgrade: false }))
24-
stats.peers = stats.peers || []
28+
29+
if (human) {
30+
stats.blocksReceived = stats.blocksReceived.toNumber()
31+
stats.blocksSent = stats.blocksSent.toNumber()
32+
stats.dataReceived = prettyBytes(stats.dataReceived.toNumber()).toUpperCase()
33+
stats.dataSent = prettyBytes(stats.dataSent.toNumber()).toUpperCase()
34+
stats.dupBlksReceived = stats.dupBlksReceived.toNumber()
35+
stats.dupDataReceived = prettyBytes(stats.dupDataReceived.toNumber()).toUpperCase()
36+
stats.wantlist = `[${stats.wantlist.length} keys]`
37+
} else {
38+
const wantlist = stats.wantlist.map((elem) => cidToString(elem['/'], { base: cidBase, upgrade: false }))
39+
stats.wantlist = `[${wantlist.length} keys]
40+
${wantlist.join('\n ')}`
41+
}
2542

2643
print(`bitswap status
27-
blocks received: ${stats.blocksReceived}
28-
dup blocks received: ${stats.dupBlksReceived}
29-
dup data received: ${stats.dupDataReceived}B
30-
wantlist [${stats.wantlist.length} keys]
31-
${stats.wantlist.join('\n ')}
32-
partners [${stats.peers.length}]
33-
${stats.peers.join('\n ')}`)
44+
provides buffer: ${stats.provideBufLen}
45+
blocks received: ${stats.blocksReceived}
46+
blocks sent: ${stats.blocksSent}
47+
data received: ${stats.dataReceived}
48+
data sent: ${stats.dataSent}
49+
dup blocks received: ${stats.dupBlksReceived}
50+
dup data received: ${stats.dupDataReceived}
51+
wantlist ${stats.wantlist}
52+
partners [${stats.peers.length}]`)
3453
})())
3554
}
3655
}

src/cli/commands/dag/put.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const mh = require('multihashes')
44
const multibase = require('multibase')
55
const dagCBOR = require('ipld-dag-cbor')
66
const dagPB = require('ipld-dag-pb')
7+
const CID = require('cids')
78
const { cidToString } = require('../../../utils/cid')
89

910
const inputDecoders = {
@@ -109,6 +110,12 @@ module.exports = {
109110

110111
source = inputDecoders[inputEncoding](source)
111112

113+
// Support legacy { "/" : "<CID>" } format so dag put is actually useful
114+
// on the command line: https://github.com/ipld/js-ipld-dag-cbor/issues/84
115+
if (inputEncoding === 'json' && format === 'dag-cbor') {
116+
source = objectSlashToCID(source)
117+
}
118+
112119
const cid = await ipfs.dag.put(source, {
113120
format,
114121
hashAlg,
@@ -122,3 +129,26 @@ module.exports = {
122129
})())
123130
}
124131
}
132+
133+
function objectSlashToCID (obj) {
134+
if (Array.isArray(obj)) {
135+
return obj.map(objectSlashToCID)
136+
}
137+
138+
if (obj && typeof obj === 'object') {
139+
const keys = Object.keys(obj)
140+
if (keys.length === 1 && '/' in obj) {
141+
if (typeof obj['/'] !== 'string') {
142+
throw new Error('link should have been a string')
143+
}
144+
return new CID(obj['/']) // throws if not a CID - consistent with go-ipfs
145+
}
146+
147+
return keys.reduce((obj, key) => {
148+
obj[key] = objectSlashToCID(obj[key])
149+
return obj
150+
}, obj)
151+
}
152+
153+
return obj
154+
}

src/cli/commands/repo/stat.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
const prettyBytes = require('pretty-bytes')
4+
35
module.exports = {
46
command: 'stat',
57

@@ -15,14 +17,23 @@ module.exports = {
1517

1618
handler (argv) {
1719
argv.resolve((async () => {
18-
const ipfs = await argv.getIpfs()
19-
const stats = await ipfs.repo.stat({ human: argv.human })
20-
argv.print(`repo status
21-
number of objects: ${stats.numObjects}
22-
repo size: ${stats.repoSize}
23-
repo path: ${stats.repoPath}
24-
version: ${stats.version}
25-
maximum storage: ${stats.storageMax}`)
20+
const { getIpfs, human } = argv
21+
22+
const ipfs = await getIpfs()
23+
const stats = await ipfs.repo.stat()
24+
25+
if (human) {
26+
stats.numObjects = stats.numObjects.toNumber()
27+
stats.repoSize = prettyBytes(stats.repoSize.toNumber()).toUpperCase()
28+
stats.storageMax = prettyBytes(stats.storageMax.toNumber()).toUpperCase()
29+
}
30+
31+
argv.print(
32+
`NumObjects: ${stats.numObjects}
33+
RepoSize: ${stats.repoSize}
34+
StorageMax: ${stats.storageMax}
35+
RepoPath: ${stats.repoPath}
36+
Version: ${stats.version}`)
2637
})())
2738
}
2839
}

src/cli/commands/swarm/connect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
}
1515
const ipfs = await argv.getIpfs()
1616
const res = await ipfs.swarm.connect(argv.address)
17-
argv.print(res.Strings[0])
17+
res.forEach(msg => argv.print(msg))
1818
})())
1919
}
2020
}

src/cli/commands/swarm/disconnect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
}
1515
const ipfs = await argv.getIpfs()
1616
const res = await ipfs.swarm.disconnect(argv.address)
17-
argv.print(res.Strings[0])
17+
res.forEach(msg => argv.print(msg))
1818
})())
1919
}
2020
}

0 commit comments

Comments
 (0)