hypercore 10.5.0 → 10.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core.js +21 -18
- package/lib/info.js +3 -2
- package/package.json +2 -2
package/lib/core.js
CHANGED
|
@@ -241,31 +241,34 @@ module.exports = class Core {
|
|
|
241
241
|
async clear (start, end) {
|
|
242
242
|
await this._mutex.lock()
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
try {
|
|
245
|
+
const entry = {
|
|
246
|
+
userData: null,
|
|
247
|
+
treeNodes: null,
|
|
248
|
+
treeUpgrade: null,
|
|
249
|
+
bitfield: {
|
|
250
|
+
start,
|
|
251
|
+
length: end - start,
|
|
252
|
+
drop: true
|
|
253
|
+
}
|
|
252
254
|
}
|
|
253
|
-
}
|
|
254
255
|
|
|
255
|
-
|
|
256
|
+
await this.oplog.append([entry], false)
|
|
256
257
|
|
|
257
|
-
|
|
258
|
+
this.bitfield.setRange(start, end - start, false)
|
|
258
259
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
if (start < this.header.contiguousLength) {
|
|
261
|
+
this.header.contiguousLength = start
|
|
262
|
+
}
|
|
262
263
|
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
start = this.bitfield.lastSet(start) + 1
|
|
265
|
+
/* TODO: this borks for some reason, so needs a fix.
|
|
266
|
+
end = this.bitfield.firstSet(end)
|
|
265
267
|
|
|
266
|
-
|
|
268
|
+
if (end === -1) end = this.tree.length
|
|
269
|
+
*/
|
|
270
|
+
while (end < this.tree.length && this.bitfield.get(end) === false) end++
|
|
267
271
|
|
|
268
|
-
try {
|
|
269
272
|
const offset = await this.tree.byteOffset(start * 2)
|
|
270
273
|
const [byteEnd, byteEndLength] = await this.tree.byteRange((end - 1) * 2)
|
|
271
274
|
const length = (byteEnd + byteEndLength) - offset
|
package/lib/info.js
CHANGED
|
@@ -39,8 +39,9 @@ module.exports = class Info {
|
|
|
39
39
|
function bytesUsed (file) {
|
|
40
40
|
return new Promise((resolve, reject) => {
|
|
41
41
|
file.stat((err, st) => {
|
|
42
|
-
if (err)
|
|
43
|
-
|
|
42
|
+
if (err) {
|
|
43
|
+
resolve(0) // prob just file not found (TODO, improve)
|
|
44
|
+
} else if (typeof st.blocks !== 'number') {
|
|
44
45
|
reject(new Error('cannot determine bytes used'))
|
|
45
46
|
} else {
|
|
46
47
|
resolve(st.blocks * 512)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.2",
|
|
4
4
|
"description": "Hypercore is a secure, distributed append-only log",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hyperswarm/secret-stream": "^6.0.0",
|
|
37
37
|
"b4a": "^1.1.0",
|
|
38
|
-
"big-sparse-array": "^1.0.
|
|
38
|
+
"big-sparse-array": "^1.0.3",
|
|
39
39
|
"compact-encoding": "^2.11.0",
|
|
40
40
|
"crc-universal": "^1.0.2",
|
|
41
41
|
"events": "^3.3.0",
|