Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.on('data', bufferData)
res.on('end', done)
})
}
const onProgress = (hash, entry, count, total) => {
this._recalculateReplicationStatus(count, entry.clock.time)
this._onLoadProgress(hash, entry)
}
// Fetch the entries
// Timeout 1 sec to only load entries that are already fetched (in order to not get stuck at loading)
const snapshotData = await loadSnapshotData()
this._recalculateReplicationMax(snapshotData.values.reduce(maxClock, 0))
if (snapshotData) {
const log = await Log.fromJSON(this._ipfs, this.identity, snapshotData, { access: this.access, sortFn: this.options.sortFn, length: -1, timeout: 1000, onProgressCallback: onProgress })
await this._oplog.join(log)
await this._updateIndex()
this.events.emit('replicated', this.address.toString())
}
this.events.emit('ready', this.address.toString(), this._oplog.heads)
} else {
throw new Error(`Snapshot for ${this.address} not found!`)
}
return this
}