File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ module.exports = class Hyperblobs {
46
46
res . push ( block )
47
47
}
48
48
} catch ( error ) {
49
- if ( error . message === 'Block not available ' ) return null
49
+ if ( error . code === 'BLOCK_NOT_AVAILABLE ' ) return null
50
50
throw error
51
51
}
52
52
Original file line number Diff line number Diff line change 1
1
const { Readable, Writable } = require ( 'streamx' )
2
+ const { BLOCK_NOT_AVAILABLE } = require ( 'hypercore/errors' )
2
3
3
4
class SparsePrefetcher {
4
5
constructor ( opts = { } ) {
@@ -121,7 +122,7 @@ class BlobReadStream extends Readable {
121
122
start : this . id . blockOffset ,
122
123
end : this . id . blockOffset + this . id . blockLength
123
124
} ) . then ( result => {
124
- if ( ! result ) return cb ( new Error ( 'Block not available' ) )
125
+ if ( ! result ) return cb ( BLOCK_NOT_AVAILABLE ( ) )
125
126
126
127
this . _index = result [ 0 ]
127
128
this . _relativeOffset = result [ 1 ]
@@ -150,7 +151,7 @@ class BlobReadStream extends Readable {
150
151
}
151
152
152
153
this . core . get ( this . _index ) . then ( block => {
153
- if ( ! block ) return cb ( new Error ( 'Block not available' ) )
154
+ if ( ! block ) return cb ( BLOCK_NOT_AVAILABLE ( ) )
154
155
155
156
const remainder = this . _end - this . _pos
156
157
if ( this . _relativeOffset || ( remainder < block . length ) ) {
Original file line number Diff line number Diff line change 23
23
"homepage" : " https://github.com/holepunchto/hyperblobs#readme" ,
24
24
"dependencies" : {
25
25
"b4a" : " ^1.6.1" ,
26
+ "hypercore" : " ^10.18.0" ,
26
27
"mutexify" : " ^1.4.0" ,
27
28
"streamx" : " ^2.13.2"
28
29
},
29
30
"devDependencies" : {
30
31
"brittle" : " ^3.1.0" ,
31
- "hypercore" : " ^10.11.0" ,
32
32
"random-access-memory" : " ^6.0.0" ,
33
33
"standard" : " ^17.0.0"
34
34
}
Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ test('read stream without waiting', async function (t) {
264
264
t . fail ( 'should not get any block: ' + block . toString ( ) )
265
265
}
266
266
} catch ( error ) {
267
- t . is ( error . message , 'Block not available ' )
267
+ t . is ( error . code , 'BLOCK_NOT_AVAILABLE ' )
268
268
}
269
269
} )
270
270
@@ -281,7 +281,7 @@ test('seek stream without waiting', async function (t) {
281
281
t . fail ( 'should not get any block: ' + block . toString ( ) )
282
282
}
283
283
} catch ( error ) {
284
- t . is ( error . message , 'Block not available ' )
284
+ t . is ( error . code , 'BLOCK_NOT_AVAILABLE ' )
285
285
}
286
286
} )
287
287
You can’t perform that action at this time.
0 commit comments