hotstuff icon indicating copy to clipboard operation
hotstuff copied to clipboard

refactor: replace IDSet with idiomatic Go

Open meling opened this issue 9 months ago • 0 comments

The IDSet is confusing for the reader and non-idiomatic Go:

// IDSet implements a set of replica IDs. It is used to show which replicas participated in some event.
type IDSet interface {
	// Add adds an ID to the set.
	Add(id ID)
	// Contains returns true if the set contains the ID.
	Contains(id ID) bool
	// ForEach calls f for each ID in the set.
	ForEach(f func(ID))
	// RangeWhile calls f for each ID in the set until f returns false.
	RangeWhile(f func(ID) bool)
	// Len returns the number of entries in the set.
	Len() int
}

We now have iterators as well. I'm opening this without a concrete solution, but once other refactors have been completed, we should get rid of IDSet in its current form.

meling avatar May 26 '25 19:05 meling