hypercore 10.15.0 → 10.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core.js +1 -1
- package/lib/oplog.js +3 -4
- package/package.json +1 -1
package/lib/core.js
CHANGED
package/lib/oplog.js
CHANGED
|
@@ -4,11 +4,11 @@ const { crc32 } = require('crc-universal')
|
|
|
4
4
|
const { OPLOG_CORRUPT } = require('./errors')
|
|
5
5
|
|
|
6
6
|
module.exports = class Oplog {
|
|
7
|
-
constructor (storage, { pageSize = 4096, headerEncoding = cenc.raw, entryEncoding = cenc.raw,
|
|
7
|
+
constructor (storage, { pageSize = 4096, headerEncoding = cenc.raw, entryEncoding = cenc.raw, readonly = false } = {}) {
|
|
8
8
|
this.storage = storage
|
|
9
9
|
this.headerEncoding = headerEncoding
|
|
10
10
|
this.entryEncoding = entryEncoding
|
|
11
|
-
this.
|
|
11
|
+
this.readonly = readonly
|
|
12
12
|
this.flushed = false
|
|
13
13
|
this.byteLength = 0
|
|
14
14
|
this.length = 0
|
|
@@ -102,8 +102,6 @@ module.exports = class Oplog {
|
|
|
102
102
|
|
|
103
103
|
result.header = header ? h2.message : h1.message
|
|
104
104
|
|
|
105
|
-
if (this.headerOnly) return result
|
|
106
|
-
|
|
107
105
|
while (true) {
|
|
108
106
|
const entry = this._decodeEntry(state, this.entryEncoding)
|
|
109
107
|
if (!entry) break
|
|
@@ -125,6 +123,7 @@ module.exports = class Oplog {
|
|
|
125
123
|
if (size === buffer.byteLength) return result
|
|
126
124
|
|
|
127
125
|
await new Promise((resolve, reject) => {
|
|
126
|
+
if (this.readonly) return resolve()
|
|
128
127
|
this.storage.truncate(size, err => {
|
|
129
128
|
if (err) return reject(err)
|
|
130
129
|
resolve()
|