Skip to content

Commit

Permalink
registerBatch supports atomicity
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Dec 19, 2024
1 parent 9bdee3f commit e934f72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++

Expand Down

0 comments on commit e934f72

Please sign in to comment.