Comparing version 6.0.30 to 6.0.31
@@ -505,14 +505,15 @@ const { EventEmitter } = require('events') | ||
let buf = await core.getUserData('autobase/view') | ||
if (buf && buf[0] !== 0) { // sniff for old record | ||
const buf = await core.getUserData('autobase/view') | ||
const record = (buf !== null && buf[0] === 0) ? c.decode(ViewRecord, buf) : { name: null, migrated: null, audits: 0 } | ||
if (record.audits === 0) { | ||
// old core, audit it real quick | ||
const corrections = await core.core.audit() | ||
if (corrections.blocks || corrections.tree) debugWarn('view', core.id, 'auto corrected itself', corrections) | ||
buf = null | ||
} | ||
const prev = !force && buf ? c.decode(ViewRecord, buf) : null | ||
const prev = (!force && record.name) ? record : null | ||
if (prev && !this.migrated) this.migrated = prev.migrated | ||
await core.setUserData('autobase/view', c.encode(ViewRecord, { name: this.name, migrated: prev ? prev.migrated : this.migrated })) | ||
await core.setUserData('autobase/view', c.encode(ViewRecord, { name: this.name, migrated: prev ? prev.migrated : this.migrated, audits: 1 })) | ||
} | ||
@@ -610,3 +611,3 @@ | ||
const blocks = this.indexBatch(0, this.indexing) | ||
const batch = await this.core.restoreBatch(this.pendingIndexedLength, blocks) | ||
const batch = await this.core.restoreBatch(this.pendingIndexedLength, { blocks, clone: false }) | ||
@@ -733,3 +734,3 @@ const signable = batch.signable(this.core.key) | ||
if (maxFlushedLength > this.core.indexedLength && this.core.flushedLength < this.core.length) { | ||
flushed = await this.core.flush({ length: maxFlushedLength, signature: null, keyPair: null }) | ||
flushed = false | ||
} | ||
@@ -746,2 +747,3 @@ | ||
if (!(await this.core.flush({ length: maxSignedlength, signature }))) return false | ||
flushed = true | ||
} | ||
@@ -756,3 +758,3 @@ | ||
const blocks = this.indexBatch(0, length - this.indexedLength) | ||
const batch = await this.core.restoreBatch(length, blocks) | ||
const batch = await this.core.restoreBatch(length, { blocks, clone: false }) | ||
@@ -803,7 +805,3 @@ return { hash: batch.hash(), length } | ||
if (this.core.session.core !== next.core) { | ||
await next.core.copyFrom(this.core.session.core, null, { | ||
sourceLength, | ||
length, | ||
additional | ||
}) | ||
await next.core.copyPrologue(this.core.session.core, { additional }) | ||
} | ||
@@ -810,0 +808,0 @@ } |
@@ -105,4 +105,5 @@ const c = require('compact-encoding') | ||
c.string.preencode(state, m.name) | ||
c.uint.preencode(state, m.migrated ? 1 : 0) | ||
c.uint.preencode(state, (m.migrated ? 1 : 0) | (m.audits ? 2 : 0)) | ||
if (m.migrated) c.fixed32.preencode(state, m.migrated) | ||
if (m.audits) c.uint.preencode(state, m.audits) | ||
}, | ||
@@ -112,4 +113,5 @@ encode (state, m) { | ||
c.string.encode(state, m.name) | ||
c.uint.encode(state, m.migrated ? 1 : 0) | ||
c.uint.encode(state, (m.migrated ? 1 : 0) | (m.audits ? 2 : 0)) | ||
if (m.migrated) c.fixed32.encode(state, m.migrated) | ||
if (m.audits) c.uint.encode(state, m.audits) | ||
}, | ||
@@ -123,6 +125,8 @@ decode (state) { | ||
const migrated = (flags & 1) ? c.fixed32.decode(state) : null | ||
const audits = (flags & 2) ? c.uint.decode(state) : 0 | ||
return { | ||
name, | ||
migrated | ||
migrated, | ||
audits | ||
} | ||
@@ -129,0 +133,0 @@ } |
{ | ||
"name": "autobase", | ||
"version": "6.0.30", | ||
"version": "6.0.31", | ||
"description": "", | ||
@@ -38,3 +38,3 @@ "main": "index.js", | ||
"hyperbee": "^2.15.0", | ||
"hypercore": "^10.33.0", | ||
"hypercore": "^10.37.1", | ||
"hypercore-crypto": "^3.4.0", | ||
@@ -41,0 +41,0 @@ "hypercore-id-encoding": "^1.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175700
4717
Updatedhypercore@^10.37.1