diff --git a/index.js b/index.js index 3d56a19c..1054ba06 100644 --- a/index.js +++ b/index.js @@ -1937,9 +1937,9 @@ module.exports = class Autobase extends ReadyResource { } // triggered from apply - async addWriter (key, { indexer = true, isIndexer = indexer } = {}) { // just compat for old version + async addWriter (key, { indexer = true, isIndexer = indexer, isBlind = false } = {}) { // just compat for old version assert(this._applying !== null, 'System changes are only allowed in apply') - await this.system.add(key, { isIndexer }) + await this.system.add(key, { isIndexer, isBlind }) const writer = (await this._getWriterByKey(key, -1, 0, false, true, null)) || this._makeWriter(key, 0, true, false) await writer.ready() diff --git a/lib/messages.js b/lib/messages.js index 298ac098..6ba5b268 100644 --- a/lib/messages.js +++ b/lib/messages.js @@ -495,7 +495,7 @@ const Member = { c.uint.preencode(state, m.length) }, encode (state, m) { - c.uint.encode(state, (m.isIndexer ? 1 : 0) | (m.isRemoved ? 2 : 0)) + c.uint.encode(state, (m.isIndexer ? 1 : 0) | (m.isRemoved ? 2 : 0) | (m.isBlind ? 4 : 0)) c.uint.encode(state, m.length) }, decode (state) { @@ -503,6 +503,7 @@ const Member = { return { isIndexer: (flags & 1) !== 0, isRemoved: (flags & 2) !== 0, + isBlind: (flags & 4) !== 0, length: c.uint.decode(state) } } diff --git a/lib/system.js b/lib/system.js index c713a892..a955fdd6 100644 --- a/lib/system.js +++ b/lib/system.js @@ -288,7 +288,7 @@ module.exports = class SystemView extends ReadyResource { return this._clockUpdates.get(b4a.toString(key, 'hex')) || 0 } - async add (key, { isIndexer = false, length = this._seenLength(key) } = {}) { + async add (key, { isIndexer = false, isBlind = false, length = this._seenLength(key) } = {}) { let wasTracked = false let wasIndexer = false @@ -300,6 +300,7 @@ module.exports = class SystemView extends ReadyResource { await this._batch.put(key, { isIndexer, isRemoved: false, + isBlind, length }, { valueEncoding: Member, @@ -315,7 +316,7 @@ module.exports = class SystemView extends ReadyResource { if (length === 0 && o.length) length = o.length - return o.isRemoved !== n.isRemoved || o.isIndexer !== n.isIndexer || o.length !== n.length + return o.isRemoved !== n.isRemoved || o.isIndexer !== n.isIndexer || o.length !== n.length || o.isBlind !== n.isBlind } }) @@ -337,11 +338,13 @@ module.exports = class SystemView extends ReadyResource { let wasTracked = false const node = await this._batch.get(key, { valueEncoding: Member, keyEncoding: MEMBERS }) + const isBlind = node.value.isBlind const length = node ? node.value.length : 0 await this._batch.put(key, { isIndexer: false, isRemoved: true, + isBlind, length }, { valueEncoding: Member,