diff --git a/pkg/bmt/bmt.go b/pkg/bmt/bmt.go index 28d65403bdc..ae3c5e95421 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) } @@ -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 { @@ -211,7 +207,6 @@ func (h *Hasher) writeNode(n *node, isLeft bool, s []byte) { } isLeft = n.isLeft n = n.parent - level++ } } diff --git a/pkg/bmt/pool.go b/pkg/bmt/pool.go index 1a7731854ae..a7f7245c40d 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 } @@ -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