diff --git a/src/Store.js b/src/Store.js index a96b8ea..3046e34 100644 --- a/src/Store.js +++ b/src/Store.js @@ -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) {