mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-14 23:32:32 +02:00
45-use-statistical-testing
Keepalive is based on per mesh and not per node. Using total ordering mechanism similar to paxos to elect a leader if leader doesn't update it's timestamp within 3 * keepAlive then give the leader a gravestone and elect the next leader. Leader is bassed on lexicographically ordered public key.
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
package lib
|
||||
|
||||
import "cmp"
|
||||
|
||||
// MapToSlice converts a map to a slice in go
|
||||
func MapValues[K comparable, V any](m map[K]V) []V {
|
||||
func MapValues[K cmp.Ordered, V any](m map[K]V) []V {
|
||||
return MapValuesWithExclude(m, map[K]struct{}{})
|
||||
}
|
||||
|
||||
func MapValuesWithExclude[K comparable, V any](m map[K]V, exclude map[K]struct{}) []V {
|
||||
func MapValuesWithExclude[K cmp.Ordered, V any](m map[K]V, exclude map[K]struct{}) []V {
|
||||
values := make([]V, len(m)-len(exclude))
|
||||
|
||||
i := 0
|
||||
@ -26,7 +28,7 @@ func MapValuesWithExclude[K comparable, V any](m map[K]V, exclude map[K]struct{}
|
||||
return values
|
||||
}
|
||||
|
||||
func MapKeys[K comparable, V any](m map[K]V) []K {
|
||||
func MapKeys[K cmp.Ordered, V any](m map[K]V) []K {
|
||||
values := make([]K, len(m))
|
||||
|
||||
i := 0
|
||||
|
Reference in New Issue
Block a user