From e3d5b3a65f91b3f2f741085eb81b69eb2f64f916 Mon Sep 17 00:00:00 2001 From: mfw78 Date: Mon, 30 Dec 2024 14:28:44 +0000 Subject: [PATCH 1/3] chore(bmt): remove dead code --- pkg/bmt/bmt.go | 5 +---- pkg/bmt/pool.go | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/bmt/bmt.go b/pkg/bmt/bmt.go index 28d65403bdc..3bd9d55bd62 100644 --- a/pkg/bmt/bmt.go +++ b/pkg/bmt/bmt.go @@ -34,7 +34,6 @@ type Hasher struct { bmt *tree // prebuilt BMT resource for flowcontrol and proofs size int // bytes written to Hasher since last Reset() pos int // index of rightmost currently open segment - offset int // offset (cursor position) within currently open segment result chan []byte // result channel errc chan error // error channel span []byte // The span of the data subsumed under the chunk @@ -49,7 +48,7 @@ func NewHasher(hasherFact func() hash.Hash) *Hasher { result: make(chan []byte), errc: make(chan error, 1), span: make([]byte, SpanSize), - bmt: newTree(conf.segmentSize, conf.maxSize, conf.depth, conf.hasher), + bmt: newTree(conf.maxSize, conf.depth, conf.hasher), } } @@ -126,7 +125,6 @@ func (h *Hasher) Write(b []byte) (int, error) { copy(h.bmt.buffer[h.size:], b) secsize := 2 * h.segmentSize from := h.size / secsize - h.offset = h.size % secsize h.size += l to := h.size / secsize if l == maxVal { @@ -143,7 +141,6 @@ func (h *Hasher) Write(b []byte) (int, error) { func (h *Hasher) Reset() { h.pos = 0 h.size = 0 - h.offset = 0 copy(h.span, zerospan) } diff --git a/pkg/bmt/pool.go b/pkg/bmt/pool.go index 1a7731854ae..d61689ea63c 100644 --- a/pkg/bmt/pool.go +++ b/pkg/bmt/pool.go @@ -65,7 +65,7 @@ func NewPool(c *Conf) *Pool { c: make(chan *tree, c.capacity), } for i := 0; i < c.capacity; i++ { - p.c <- newTree(p.segmentSize, p.maxSize, p.depth, p.hasher) + p.c <- newTree(p.maxSize, p.depth, p.hasher) } return p } @@ -118,7 +118,7 @@ func newNode(index int, parent *node, hasher hash.Hash) *node { // newTree initialises a tree by building up the nodes of a BMT // // segmentSize is stipulated to be the size of the hash. -func newTree(segmentSize, maxsize, depth int, hashfunc func() hash.Hash) *tree { +func newTree(maxsize, depth int, hashfunc func() hash.Hash) *tree { n := newNode(0, nil, hashfunc()) prevlevel := []*node{n} // iterate over levels and creates 2^(depth-level) nodes From 59b2fbe6a11493f1fbedf13f13b8636184d41b1a Mon Sep 17 00:00:00 2001 From: mfw78 Date: Thu, 2 Jan 2025 12:12:56 +0000 Subject: [PATCH 2/3] chore(bmt): remove dead level --- pkg/bmt/bmt.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/bmt/bmt.go b/pkg/bmt/bmt.go index 3bd9d55bd62..ae3c5e95421 100644 --- a/pkg/bmt/bmt.go +++ b/pkg/bmt/bmt.go @@ -179,7 +179,6 @@ func (h *Hasher) processSection(i int, final bool) { // since hashing the parent is synchronous the same hasher can be used. func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) { var err error - level := 1 for { // at the root of the bmt just write the result to the result channel if n == nil { @@ -208,7 +207,6 @@ func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) { } isLeft = n.isLeft n = n.parent - level++ } } From a9746d764468e25f0fb86e9c857b07588e152922 Mon Sep 17 00:00:00 2001 From: mfw78 Date: Tue, 14 Jan 2025 07:57:39 +0000 Subject: [PATCH 3/3] fix(bmt): remove dead doc --- pkg/bmt/pool.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/bmt/pool.go b/pkg/bmt/pool.go index d61689ea63c..a7f7245c40d 100644 --- a/pkg/bmt/pool.go +++ b/pkg/bmt/pool.go @@ -116,8 +116,6 @@ func newNode(index int, parent *node, hasher hash.Hash) *node { } // newTree initialises a tree by building up the nodes of a BMT -// -// segmentSize is stipulated to be the size of the hash. func newTree(maxsize, depth int, hashfunc func() hash.Hash) *tree { n := newNode(0, nil, hashfunc()) prevlevel := []*node{n}