hypercore 10.32.3 → 10.32.4

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.
@@ -1,4 +1,5 @@
1
1
  const b4a = require('b4a')
2
+ const { WRITE_FAILED } = require('hypercore-errors')
2
3
 
3
4
  module.exports = class BlockStore {
4
5
  constructor (storage, tree) {
@@ -54,7 +55,7 @@ module.exports = class BlockStore {
54
55
  _write (offset, data) {
55
56
  return new Promise((resolve, reject) => {
56
57
  this.storage.write(offset, data, (err) => {
57
- if (err) reject(err)
58
+ if (err) reject(WRITE_FAILED(err.message))
58
59
  else resolve(offset + data.byteLength)
59
60
  })
60
61
  })
package/lib/messages.js CHANGED
@@ -114,7 +114,7 @@ const manifestv0 = {
114
114
  signer.encode(state, m.signers[0])
115
115
  } else {
116
116
  c.uint.encode(state, 2)
117
- c.uint.encode(state, m.allowPatched ? 1 : 0)
117
+ c.uint.encode(state, m.allowPatch ? 1 : 0)
118
118
  c.uint.encode(state, m.quorum)
119
119
  signerArray.encode(state, m.signers)
120
120
  }
package/lib/oplog.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const cenc = require('compact-encoding')
2
2
  const b4a = require('b4a')
3
3
  const { crc32 } = require('crc-universal')
4
- const { OPLOG_CORRUPT, OPLOG_HEADER_OVERFLOW } = require('hypercore-errors')
4
+ const { OPLOG_CORRUPT, OPLOG_HEADER_OVERFLOW, WRITE_FAILED } = require('hypercore-errors')
5
5
 
6
6
  module.exports = class Oplog {
7
7
  constructor (storage, { pageSize = 4096, headerEncoding = cenc.raw, entryEncoding = cenc.raw, readonly = false } = {}) {
@@ -216,7 +216,7 @@ module.exports = class Oplog {
216
216
  _append (buf, count) {
217
217
  return new Promise((resolve, reject) => {
218
218
  this.storage.write(this._entryOffset + this.byteLength, buf, err => {
219
- if (err) return reject(err)
219
+ if (err) return reject(WRITE_FAILED(err.message))
220
220
 
221
221
  this.byteLength += buf.byteLength
222
222
  this.length += count
package/lib/replicator.js CHANGED
@@ -706,6 +706,14 @@ class Peer {
706
706
  }
707
707
  } catch (err) {
708
708
  safetyCatch(err)
709
+
710
+ if (err.code === 'WRITE_FAILED') {
711
+ // For example, we don't want to keep pulling data when storage is full
712
+ // TODO: notify the user somehow
713
+ this.paused = true
714
+ return
715
+ }
716
+
709
717
  if (this.core.closed && !isCriticalError(err)) return
710
718
 
711
719
  if (err.code !== 'INVALID_OPERATION') {
package/lib/verifier.js CHANGED
@@ -73,7 +73,7 @@ module.exports = class Verifier {
73
73
 
74
74
  return {
75
75
  proofs: proofs.map(proofToVersion1),
76
- patch: patch
76
+ patch
77
77
  }
78
78
  }
79
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.32.3",
3
+ "version": "10.32.4",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -44,7 +44,7 @@
44
44
  "fast-fifo": "^1.3.0",
45
45
  "flat-tree": "^1.9.0",
46
46
  "hypercore-crypto": "^3.2.1",
47
- "hypercore-errors": "^1.1.0",
47
+ "hypercore-errors": "^1.1.1",
48
48
  "hypercore-id-encoding": "^1.2.0",
49
49
  "hypertrace": "^1.2.1",
50
50
  "is-options": "^1.0.1",