Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Create basic implementation for _addOperationBatch #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,23 @@ class Store {
}
}

_addOperationBatch (data, batchOperation, lastOperation, onProgressCallback) {
throw new Error('Not implemented!')
async _addOperationBatch (data, batchOperation, lastOperation, onProgressCallback) {

if (this._oplog) {
const entry = await this._oplog.append(data, this.options.referenceCount)
this._recalculateReplicationStatus(this.replicationStatus.progress + 1, entry.clock.time)

if (lastOperation) {
await this._cache.set('_localHeads', [entry])
await this._updateIndex()
}

this.events.emit('write', this.address.toString(), entry, this._oplog.heads)
if (onProgressCallback) onProgressCallback(entry)
return entry.cid

}

}

_onLoadProgress (cid, entry, progress, total) {
Expand Down