Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Use hrw validation function to validate netmap normalization #33

Open
alexvanin opened this issue Jul 31, 2019 · 2 comments
Open

Use hrw validation function to validate netmap normalization #33

alexvanin opened this issue Jul 31, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@alexvanin
Copy link
Contributor

With nspcc-dev/hrw#7 we can use normalization check before HRW sorting. Something like this in GetSelection()

	if ss[0].Key == NodesBucket {
		if len(b.nodes) < count {
			return nil
		}

		nodes := make(Nodes, len(b.nodes))
		copy(nodes, b.nodes)
		if len(pivot) != 0 {
			w := nodes.Weights()
			if hrw.ValidateWeights(w) != nil {
				return nil
			}
			hrw.SortSliceByWeightValue(nodes, w, pivotHash)
		}
		root.nodes = nodes[:count]
		return &root
	}
@im-kulikov
Copy link
Contributor

@alexvanin #7 is merged, mb we can close this issue?

@alexvanin
Copy link
Contributor Author

@im-kulikov We can implement the proposal above or decline it. I proposed to do weight validation before HRW sorting.

if hrw.ValidateWeights(w) != nil {
	return nil
}
hrw.SortSliceByWeightValue(nodes, w, pivotHash)

Since this library contains explicit normalizers I think we can avoid any changes for extra weight validation. I think we can close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants