Skip to content

Commit

Permalink
Unslab merkle-tree signatures (#542)
Browse files Browse the repository at this point in the history
* Unslab merkle-tree signatures

* No getter/setter
  • Loading branch information
HDegroote authored Jul 26, 2024
1 parent c311102 commit 801c9cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/merkle-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class MerkleTreeBatch {
this.tree.length = this.length
this.tree.byteLength = this.byteLength
this.tree.fork = this.fork
this.tree.signature = this.signature
this.tree.signature = this.signature !== null ? unslab(this.signature) : null
}

seek (bytes, padding) {
Expand Down Expand Up @@ -429,7 +429,7 @@ module.exports = class MerkleTree {
this.roots = roots
this.length = roots.length ? totalSpan(roots) / 2 : 0
this.byteLength = totalSize(roots)
this.signature = signature
this.signature = signature !== null ? unslab(signature) : null
this.prologue = prologue

this.storage = storage
Expand Down
15 changes: 15 additions & 0 deletions test/replicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,21 @@ test('handshake is unslabbed', async function (t) {
)
})

test('merkle-tree signature gets unslabbed', async function (t) {
const a = await create()
await a.append(['a'])

const b = await create(a.key)
replicate(a, b, t)
await b.get(0)

t.is(
b.core.tree.signature.buffer.byteLength,
64,
'Signature got unslabbed'
)
})

async function waitForRequestBlock (core) {
while (true) {
const reqBlock = core.replicator._inflight._requests.find(req => req && req.block)
Expand Down

0 comments on commit 801c9cf

Please sign in to comment.