hypercore 10.33.0 → 10.33.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/index.js +11 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -29,6 +29,10 @@ const {
|
|
|
29
29
|
const promises = Symbol.for('hypercore.promises')
|
|
30
30
|
const inspect = Symbol.for('nodejs.util.inspect.custom')
|
|
31
31
|
|
|
32
|
+
// Hypercore actually does not have any notion of max/min block sizes
|
|
33
|
+
// but we enforce 15mb to ensure smooth replication (each block is transmitted atomically)
|
|
34
|
+
const MAX_SUGGESTED_BLOCK_SIZE = 15 * 1024 * 1024
|
|
35
|
+
|
|
32
36
|
module.exports = class Hypercore extends EventEmitter {
|
|
33
37
|
constructor (storage, key, opts) {
|
|
34
38
|
super()
|
|
@@ -134,6 +138,8 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
134
138
|
indent + ')'
|
|
135
139
|
}
|
|
136
140
|
|
|
141
|
+
static MAX_SUGGESTED_BLOCK_SIZE = MAX_SUGGESTED_BLOCK_SIZE
|
|
142
|
+
|
|
137
143
|
static key (manifest, { compat } = {}) {
|
|
138
144
|
return compat ? manifest.signers[0].publicKey : manifestHash(createManifest(manifest))
|
|
139
145
|
}
|
|
@@ -1024,6 +1030,11 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
1024
1030
|
buffers[i] = this._encode(this.valueEncoding, blocks[i])
|
|
1025
1031
|
}
|
|
1026
1032
|
}
|
|
1033
|
+
for (const b of buffers) {
|
|
1034
|
+
if (b.byteLength > MAX_SUGGESTED_BLOCK_SIZE) {
|
|
1035
|
+
throw BAD_ARGUMENT('Appended block exceeds the maximum suggested block size')
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1027
1038
|
|
|
1028
1039
|
return this.core.append(buffers, { keyPair, signature, preappend })
|
|
1029
1040
|
}
|