Comparing version
@@ -20,3 +20,2 @@ const b4a = require('b4a') | ||
this.batch = null | ||
this.atomicCore = null | ||
this.atomicBatch = null | ||
@@ -44,2 +43,30 @@ this.extension = null | ||
async matchesKey (key) { | ||
if (!this.core.opened) await this.core.ready() | ||
if (b4a.equals(this.core.key, key)) return true | ||
if (!this.atomicBatch) return false | ||
if (!this.atomicBatch.opened) await this.atomicBatch.ready() | ||
return b4a.equals(this.atomicBatch.key, key) | ||
} | ||
async matchesNamespace (target) { | ||
if (!this.core.opened) await this.core.ready() | ||
if (this.core.manifest && this.core.manifest.signers.length > 0) { | ||
const ns = this.core.manifest.signers[0].namespace | ||
if (b4a.equals(ns, target)) return true | ||
} | ||
if (!this.atomicBatch) return false | ||
if (this.atomicBatch.manifest && this.atomicBatch.manifest.signers.length > 0) { | ||
const ns = this.atomicBatch.manifest.signers[0].namespace | ||
if (b4a.equals(ns, target)) return true | ||
} | ||
return false | ||
} | ||
async commit (atom, length, signature) { | ||
@@ -55,7 +82,2 @@ // TODO: is this how its supposed be done atomic wise? | ||
} | ||
if (this.atomicCore) { | ||
await this.atomicCore.close() | ||
this.atomicCore = null | ||
} | ||
} | ||
@@ -301,4 +323,3 @@ | ||
for (const v of this.byName.values()) { | ||
if (!v.core.opened) await v.core.ready() | ||
if (b4a.equals(v.core.key, key)) return v | ||
if (await v.matchesKey(key)) return v | ||
} | ||
@@ -313,7 +334,3 @@ | ||
for (const v of this.byName.values()) { | ||
if (!v.core.opened) await v.core.ready() | ||
if (!v.core.manifest) continue | ||
if (!v.core.manifest.signers.length) continue | ||
const ns = v.core.manifest.signers[0].namespace | ||
if (b4a.equals(ns, target)) return v | ||
if (await v.matchesNamespace(target)) return v | ||
} | ||
@@ -320,0 +337,0 @@ |
{ | ||
"name": "autobase", | ||
"version": "7.0.7", | ||
"version": "7.0.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
169184
0.28%4511
0.22%