Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bmt): remove dead code #4943

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading