mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
Co-authored-by: Dan Laine <daniel.laine@avalabs.org> Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
a74b7e2466
commit
222d180a6b
1 changed files with 2 additions and 2 deletions
|
|
@ -100,12 +100,12 @@ func NewNodeSet(owner common.Hash) *NodeSet {
|
||||||
// ForEachWithOrder iterates the nodes with the order from bottom to top,
|
// ForEachWithOrder iterates the nodes with the order from bottom to top,
|
||||||
// right to left, nodes with the longest path will be iterated first.
|
// right to left, nodes with the longest path will be iterated first.
|
||||||
func (set *NodeSet) ForEachWithOrder(callback func(path string, n *Node)) {
|
func (set *NodeSet) ForEachWithOrder(callback func(path string, n *Node)) {
|
||||||
var paths sort.StringSlice
|
paths := make([]string, 0, len(set.Nodes))
|
||||||
for path := range set.Nodes {
|
for path := range set.Nodes {
|
||||||
paths = append(paths, path)
|
paths = append(paths, path)
|
||||||
}
|
}
|
||||||
// Bottom-up, longest path first
|
// Bottom-up, longest path first
|
||||||
sort.Sort(sort.Reverse(paths))
|
sort.Sort(sort.Reverse(sort.StringSlice(paths)))
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
callback(path, set.Nodes[path].Unwrap())
|
callback(path, set.Nodes[path].Unwrap())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue