Skip to content

Commit

Permalink
chore(bmt): remove dead code (#4943)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfw78 authored Jan 22, 2025
1 parent 1a92dce commit dec3c3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions pkg/bmt/bmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down Expand Up @@ -182,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 {
Expand Down Expand Up @@ -211,7 +207,6 @@ func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) {
}
isLeft = n.isLeft
n = n.parent
level++
}
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/bmt/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -116,9 +116,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
Expand Down

0 comments on commit dec3c3b

Please sign in to comment.