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

Commit

Permalink
improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
tabcat committed Mar 31, 2020
1 parent a71d2d2 commit b618c6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,22 +486,23 @@ class Store {
}

async _addOperation (data, { onProgressCallback, pin = false } = {}) {
return this._opqueue.add(async () => {
async function addOperation () {
if (this._oplog) {
// check local cache?
if (this.options.syncLocal) {
await this.syncLocal()
}

const entry = await this._oplog.append(data, this.options.referenceCount, pin)
const entry = await this._oplog.append(data, this.options.referenceCount)
this._recalculateReplicationStatus(this.replicationStatus.progress + 1, entry.clock.time)
await this._cache.set(this.localHeadsPath, [entry])
await this._updateIndex()
this.events.emit('write', this.address.toString(), entry, this._oplog.heads)
if (onProgressCallback) onProgressCallback(entry)
return entry.hash
}
})
}
return this._opqueue.add(addOperation.bind(this))
}

_addOperationBatch (data, batchOperation, lastOperation, onProgressCallback) {
Expand Down

0 comments on commit b618c6a

Please sign in to comment.