hypercore 11.18.0 → 11.18.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 -2
- package/lib/read-batch.js +10 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -977,9 +977,18 @@ class Hypercore extends EventEmitter {
|
|
|
977
977
|
async proof(opts) {
|
|
978
978
|
if (this.opened === false) await this.opening
|
|
979
979
|
const rx = this.state.storage.read()
|
|
980
|
-
const
|
|
980
|
+
const proofPromise = MerkleTree.proof(this.state, rx, opts)
|
|
981
|
+
const blockPromise = opts && opts.block ? rx.getBlock(opts.block.index) : null
|
|
981
982
|
rx.tryFlush()
|
|
982
|
-
|
|
983
|
+
const [proof, block] = await Promise.all([proofPromise, blockPromise])
|
|
984
|
+
const settled = await proof.settle()
|
|
985
|
+
if (block) settled.block.value = block
|
|
986
|
+
return settled
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
async applyProof(proof, from) {
|
|
990
|
+
if (this.opened === false) await this.opening
|
|
991
|
+
return this.core.verify(proof, from)
|
|
983
992
|
}
|
|
984
993
|
|
|
985
994
|
async verifyFullyRemote(proof) {
|