This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 5 files changed +18
-11
lines changed
5 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const CID = require ( 'cids' )
4
3
const print = require ( '../../utils' ) . print
5
4
6
5
module . exports = {
@@ -17,11 +16,7 @@ module.exports = {
17
16
}
18
17
19
18
stats . wantlist = stats . wantlist || [ ]
20
- stats . wantlist = stats . wantlist . map ( ( entry ) => {
21
- const buf = Buffer . from ( entry . cid . hash . data )
22
- const cid = new CID ( entry . cid . version , entry . cid . codec , buf )
23
- return cid . toBaseEncodedString ( )
24
- } )
19
+ stats . wantlist = stats . wantlist . map ( entry => entry [ '/' ] )
25
20
stats . peers = stats . peers || [ ]
26
21
27
22
print ( `bitswap status
Original file line number Diff line number Diff line change 3
3
const print = require ( '../../utils' ) . print
4
4
5
5
module . exports = {
6
- command : 'wantlist' ,
6
+ command : 'wantlist [peer] ' ,
7
7
8
8
describe : 'Print out all blocks currently on the bitswap wantlist for the local peer.' ,
9
9
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ module.exports = {
19
19
}
20
20
21
21
if ( block ) {
22
- process . stdout . write ( block . data )
22
+ print ( block . data )
23
23
} else {
24
- process . stderr . write ( 'Block was unwanted before it could be remotely retrieved' )
24
+ print ( 'Block was unwanted before it could be remotely retrieved' )
25
25
}
26
26
} )
27
27
}
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ exports = module.exports
9
9
exports . wantlist = {
10
10
handler : ( request , reply ) => {
11
11
const peerId = request . query . arg
12
- let list
13
12
request . server . app . ipfs . bitswap . wantlist ( peerId , ( err , list ) => {
14
13
if ( err ) {
15
14
return reply ( boom . badRequest ( err ) )
Original file line number Diff line number Diff line change 3
3
4
4
const expect = require ( 'chai' ) . expect
5
5
const runOn = require ( '../utils/on-and-off' ) . on
6
+ const PeerId = require ( 'peer-id' )
6
7
7
8
describe ( 'bitswap' , ( ) => runOn ( ( thing ) => {
8
9
let ipfs
10
+ let peerId
9
11
const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
10
12
11
13
before ( ( done ) => {
12
14
ipfs = thing . ipfs
13
15
ipfs ( 'block get ' + key )
14
16
. then ( ( ) => { } )
15
17
. catch ( ( ) => { } )
16
- setTimeout ( done , 250 )
18
+ PeerId . create ( ( err , peer ) => {
19
+ expect ( err ) . to . not . exist ( )
20
+ peerId = peer . toB58String ( )
21
+ setTimeout ( done , 250 )
22
+ } )
17
23
} )
18
24
19
25
it ( 'wantlist' , function ( ) {
@@ -23,6 +29,13 @@ describe('bitswap', () => runOn((thing) => {
23
29
} )
24
30
} )
25
31
32
+ it ( 'wantlist peerid' , function ( ) {
33
+ this . timeout ( 20 * 1000 )
34
+ return ipfs ( 'bitswap wantlist ' + peerId ) . then ( ( out ) => {
35
+ expect ( out ) . to . eql ( '' )
36
+ } )
37
+ } )
38
+
26
39
it ( 'stat' , function ( ) {
27
40
this . timeout ( 20 * 1000 )
28
41
You can’t perform that action at this time.
0 commit comments