From de01dee01ad23bbfdeb4e630ef76b2f5e5b97fc4 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 13 Mar 2024 20:01:36 -0400 Subject: [PATCH] chore: remove unneeded func --- lib/blocktree/node.go | 46 +++++++++++++------------------------------ 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/lib/blocktree/node.go b/lib/blocktree/node.go index 1640e2786f..5eb4556860 100644 --- a/lib/blocktree/node.go +++ b/lib/blocktree/node.go @@ -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 @@ -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 -}