Skip to content

Commit

Permalink
chore: remove unneeded func
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Mar 14, 2024
1 parent 5c4d2e1 commit de01dee
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions lib/blocktree/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,23 @@ func (n *node) getNode(h common.Hash) *node {
return nil
}

// getNodesWithNumber returns all descendent nodes with the desired number
func (n *node) getNodesWithNumber(number uint, hashes []common.Hash) []common.Hash {
for _, child := range n.children {
// number matches
if child.number == number {
hashes = append(hashes, child.hash)
}
// hashesAtNumber returns all nodes in the chain that contains the desired number
func (n *node) hashesAtNumber(number uint, hashes []common.Hash) []common.Hash {
// there is no need to go furthen in the node's children
// since they have a greater number at least
if number == n.number {
hashes = append(hashes, n.hash)
return hashes
}

// are deeper than desired number, return
if child.number > number {
return hashes
// if the number is greater than current node,
// then search among its children
if number > n.number {
for _, children := range n.children {
hashes = children.hashesAtNumber(number, hashes)
}

hashes = child.getNodesWithNumber(number, hashes)
return hashes
}

return hashes
Expand Down Expand Up @@ -210,24 +213,3 @@ func (n *node) primaryAncestorCount(count int) int {

return n.parent.primaryAncestorCount(count)
}

func (n *node) hashesAtNumber(number uint, hashes []common.Hash) []common.Hash {
// there is no need to go furthen in the node's children
// since they have a greater number at least
if number == n.number {
hashes = append(hashes, n.hash)
return hashes
}

// if the number is greater than current node,
// then search among its children
if number > n.number {
for _, children := range n.children {
hashes = children.hashesAtNumber(number, hashes)
}

return hashes
}

return hashes
}

0 comments on commit de01dee

Please sign in to comment.