From 2629886af4e022c651a2e07b81e2d13a82aa3075 Mon Sep 17 00:00:00 2001 From: Patrick Toner Date: Sun, 28 Apr 2019 10:11:05 -0400 Subject: [PATCH] Create basic implementation for _addOperationBatch --- src/Store.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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) {