Skip to content

Commit dec3c3b

Browse files
authored
chore(bmt): remove dead code (#4943)
1 parent 1a92dce commit dec3c3b

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

pkg/bmt/bmt.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type Hasher struct {
3434
bmt *tree // prebuilt BMT resource for flowcontrol and proofs
3535
size int // bytes written to Hasher since last Reset()
3636
pos int // index of rightmost currently open segment
37-
offset int // offset (cursor position) within currently open segment
3837
result chan []byte // result channel
3938
errc chan error // error channel
4039
span []byte // The span of the data subsumed under the chunk
@@ -49,7 +48,7 @@ func NewHasher(hasherFact func() hash.Hash) *Hasher {
4948
result: make(chan []byte),
5049
errc: make(chan error, 1),
5150
span: make([]byte, SpanSize),
52-
bmt: newTree(conf.segmentSize, conf.maxSize, conf.depth, conf.hasher),
51+
bmt: newTree(conf.maxSize, conf.depth, conf.hasher),
5352
}
5453
}
5554

@@ -126,7 +125,6 @@ func (h *Hasher) Write(b []byte) (int, error) {
126125
copy(h.bmt.buffer[h.size:], b)
127126
secsize := 2 * h.segmentSize
128127
from := h.size / secsize
129-
h.offset = h.size % secsize
130128
h.size += l
131129
to := h.size / secsize
132130
if l == maxVal {
@@ -143,7 +141,6 @@ func (h *Hasher) Write(b []byte) (int, error) {
143141
func (h *Hasher) Reset() {
144142
h.pos = 0
145143
h.size = 0
146-
h.offset = 0
147144
copy(h.span, zerospan)
148145
}
149146

@@ -182,7 +179,6 @@ func (h *Hasher) processSection(i int, final bool) {
182179
// since hashing the parent is synchronous the same hasher can be used.
183180
func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) {
184181
var err error
185-
level := 1
186182
for {
187183
// at the root of the bmt just write the result to the result channel
188184
if n == nil {
@@ -211,7 +207,6 @@ func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) {
211207
}
212208
isLeft = n.isLeft
213209
n = n.parent
214-
level++
215210
}
216211
}
217212

pkg/bmt/pool.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewPool(c *Conf) *Pool {
6565
c: make(chan *tree, c.capacity),
6666
}
6767
for i := 0; i < c.capacity; i++ {
68-
p.c <- newTree(p.segmentSize, p.maxSize, p.depth, p.hasher)
68+
p.c <- newTree(p.maxSize, p.depth, p.hasher)
6969
}
7070
return p
7171
}
@@ -116,9 +116,7 @@ func newNode(index int, parent *node, hasher hash.Hash) *node {
116116
}
117117

118118
// newTree initialises a tree by building up the nodes of a BMT
119-
//
120-
// segmentSize is stipulated to be the size of the hash.
121-
func newTree(segmentSize, maxsize, depth int, hashfunc func() hash.Hash) *tree {
119+
func newTree(maxsize, depth int, hashfunc func() hash.Hash) *tree {
122120
n := newNode(0, nil, hashfunc())
123121
prevlevel := []*node{n}
124122
// iterate over levels and creates 2^(depth-level) nodes

0 commit comments

Comments
 (0)