From e934f7216130547acc37313a1a2c2519bd11b21e Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Thu, 19 Dec 2024 14:54:39 +0000 Subject: [PATCH] registerBatch supports atomicity --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7596406..b5aaf53 100644 --- a/index.js +++ b/index.js @@ -596,14 +596,14 @@ class HypercoreStorage { return storage } - async registerBatch (name, head) { + async registerBatch (name, head, atom) { await this.mutex.write.lock() const storage = new HypercoreStorage(this.root, this.discoveryKey, this.corePointer, this.dataPointer, null) try { const info = await getStorageInfo(this.db) - const write = this.db.write() + const write = atom ? atom.createBatch() : this.db.write() storage.dataPointer = info.free++