Skip to content

Commit

Permalink
chore(bmt): remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
mfw78 committed Dec 30, 2024
1 parent c7503d4 commit e3d5b3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 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
4 changes: 2 additions & 2 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 @@ -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
Expand Down

0 comments on commit e3d5b3a

Please sign in to comment.