hypercore-storage 1.2.0 → 1.2.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/index.js +2 -2
- package/migrations/0/index.js +23 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -287,9 +287,9 @@ class HypercoreStorage {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
class CorestoreStorage {
|
|
290
|
-
constructor (db) {
|
|
290
|
+
constructor (db, opts) {
|
|
291
291
|
this.path = typeof db === 'string' ? db : db.path
|
|
292
|
-
this.rocks = typeof db === 'string' ? new RocksDB(db) : db
|
|
292
|
+
this.rocks = typeof db === 'string' ? new RocksDB(db, opts) : db
|
|
293
293
|
this.db = createColumnFamily(this.rocks)
|
|
294
294
|
this.view = null
|
|
295
295
|
this.enters = 0
|
package/migrations/0/index.js
CHANGED
|
@@ -605,24 +605,35 @@ function readOplog (oplog) {
|
|
|
605
605
|
result.header = header ? h2.message : h1.message
|
|
606
606
|
|
|
607
607
|
if (result.header.external) {
|
|
608
|
-
|
|
608
|
+
fs.readFile(path.join(oplog, '../header'), function (err, buffer) {
|
|
609
|
+
if (err) return resolve(null)
|
|
610
|
+
const start = result.header.external.start
|
|
611
|
+
const end = start + result.header.external.length
|
|
612
|
+
result.header = m.oplog.header.decode({ buffer, start, end })
|
|
613
|
+
finish()
|
|
614
|
+
})
|
|
615
|
+
return
|
|
609
616
|
}
|
|
610
617
|
|
|
611
|
-
|
|
612
|
-
const entry = decodeOplogEntry(state)
|
|
613
|
-
if (!entry) break
|
|
614
|
-
if (entry.header !== header) break
|
|
618
|
+
finish()
|
|
615
619
|
|
|
616
|
-
|
|
617
|
-
|
|
620
|
+
function finish () {
|
|
621
|
+
while (true) {
|
|
622
|
+
const entry = decodeOplogEntry(state)
|
|
623
|
+
if (!entry) break
|
|
624
|
+
if (entry.header !== header) break
|
|
618
625
|
|
|
619
|
-
|
|
626
|
+
decoded.push(entry)
|
|
627
|
+
}
|
|
620
628
|
|
|
621
|
-
|
|
622
|
-
result.entries.push(e.message)
|
|
623
|
-
}
|
|
629
|
+
while (decoded.length > 0 && decoded[decoded.length - 1].partial) decoded.pop()
|
|
624
630
|
|
|
625
|
-
|
|
631
|
+
for (const e of decoded) {
|
|
632
|
+
result.entries.push(e.message)
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
resolve(result)
|
|
636
|
+
}
|
|
626
637
|
})
|
|
627
638
|
})
|
|
628
639
|
}
|