hypercore-storage 1.1.6 → 1.2.1
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/migrations/0/index.js +23 -12
- package/migrations/0/messages.js +4 -2
- package/package.json +1 -1
- package/spec/hyperschema/index.js +5 -3
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
|
}
|
package/migrations/0/messages.js
CHANGED
|
@@ -180,7 +180,7 @@ const manifest = exports.manifest = {
|
|
|
180
180
|
c.uint.encode(state, m.version)
|
|
181
181
|
if (m.version === 0) return manifestv0.encode(state, m)
|
|
182
182
|
|
|
183
|
-
c.uint.encode(state, (m.allowPatch ? 1 : 0) | (m.prologue ? 2 : 0))
|
|
183
|
+
c.uint.encode(state, (m.allowPatch ? 1 : 0) | (m.prologue ? 2 : 0) | (m.unencrypted ? 4 : 0))
|
|
184
184
|
hashes.encode(state, m.hash)
|
|
185
185
|
|
|
186
186
|
c.uint.encode(state, m.quorum)
|
|
@@ -196,6 +196,7 @@ const manifest = exports.manifest = {
|
|
|
196
196
|
const hash = hashes.decode(state)
|
|
197
197
|
const quorum = c.uint.decode(state)
|
|
198
198
|
const signers = signerArray.decode(state)
|
|
199
|
+
const unencrypted = (flags & 4) !== 0
|
|
199
200
|
|
|
200
201
|
return {
|
|
201
202
|
version: 1,
|
|
@@ -203,7 +204,8 @@ const manifest = exports.manifest = {
|
|
|
203
204
|
allowPatch: (flags & 1) !== 0,
|
|
204
205
|
quorum,
|
|
205
206
|
signers,
|
|
206
|
-
prologue: (flags & 2) === 0 ? null : prologue.decode(state)
|
|
207
|
+
prologue: (flags & 2) === 0 ? null : prologue.decode(state),
|
|
208
|
+
unencrypted
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
}
|
package/package.json
CHANGED
|
@@ -250,7 +250,7 @@ const encoding9_4 = c.array(encoding7)
|
|
|
250
250
|
const encoding9 = {
|
|
251
251
|
preencode (state, m) {
|
|
252
252
|
c.uint.preencode(state, m.version)
|
|
253
|
-
state.end++ // max flag is
|
|
253
|
+
state.end++ // max flag is 4 so always one byte
|
|
254
254
|
encoding4.preencode(state, m.hash)
|
|
255
255
|
c.uint.preencode(state, m.quorum)
|
|
256
256
|
encoding9_4.preencode(state, m.signers)
|
|
@@ -260,7 +260,8 @@ const encoding9 = {
|
|
|
260
260
|
encode (state, m) {
|
|
261
261
|
const flags =
|
|
262
262
|
(m.allowPatch ? 1 : 0) |
|
|
263
|
-
(m.prologue ? 2 : 0)
|
|
263
|
+
(m.prologue ? 2 : 0) |
|
|
264
|
+
(m.unencrypted ? 4 : 0)
|
|
264
265
|
|
|
265
266
|
c.uint.encode(state, m.version)
|
|
266
267
|
c.uint.encode(state, flags)
|
|
@@ -280,7 +281,8 @@ const encoding9 = {
|
|
|
280
281
|
quorum: c.uint.decode(state),
|
|
281
282
|
allowPatch: (flags & 1) !== 0,
|
|
282
283
|
signers: encoding9_4.decode(state),
|
|
283
|
-
prologue: (flags & 2) !== 0 ? encoding8.decode(state) : null
|
|
284
|
+
prologue: (flags & 2) !== 0 ? encoding8.decode(state) : null,
|
|
285
|
+
unencrypted: (flags & 4) !== 0
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
288
|
}
|