util

package
v2.0.6-testnet Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDKGsInFlight = 20

MaxDKGsInFlight is an arbitrary limit set for the number of DKGs in flight to avoid overallocating channel capacity for the fanout channel

Variables

This section is empty.

Functions

func Concat

func Concat[T any](arrs ...[]T) []T

Concat combines multiple arrays of the same type into a single array

func Cont

func Cont[T comparable](haystack []T, needle T) bool

Cont is contains, but the util package already contains another func just for `Participant`

func Contains

func Contains(haystack []*drand.Participant, needle *drand.Participant) bool

func ContainsAll

func ContainsAll(haystack, needles []*drand.Participant) bool

func EqualParticipant

func EqualParticipant(p1, p2 *drand.Participant) bool

func ErrorContains

func ErrorContains(err error, str string) bool

func Filter

func Filter[T any](arr []T, predicate func(T) bool) []T

func First

func First[T any](haystack []T, predicate func(T) bool) (*T, error)

func NonEmpty

func NonEmpty(p *drand.Participant) bool

func ParseGroupFileBytes

func ParseGroupFileBytes(groupFileBytes []byte) (*key.Group, error)

func PublicKeyAsParticipant

func PublicKeyAsParticipant(identity *key.Identity) (*drand.Participant, error)

func SortedByPublicKey

func SortedByPublicKey(arr []*drand.Participant) []*drand.Participant

func ToKeyNode

func ToKeyNode(index int, participant *drand.Participant, sch *crypto.Scheme) (key.Node, error)

func ToNode

func ToNode(index int, participant *drand.Participant, sch *crypto.Scheme) (dkg.Node, error)

func ToParticipant

func ToParticipant(node *proto.Node) *drand.Participant

func ToPeer

func ToPeer(participant *drand.Participant) net.Peer

func TryMapEach

func TryMapEach[T any](arr []*drand.Participant, fn func(index int, participant *drand.Participant) (T, error)) ([]T, error)

func Without

func Without(haystack []*drand.Participant, needle *drand.Participant) []*drand.Participant

Without removes needle from the haystack. Careful: it modifies the input slice but also returns the resulting slice. It removes all instances of needle, and zeros the removed items to allow garbage collection.

Types

type FanOutChan

type FanOutChan[T any] struct {
	// contains filtered or unexported fields
}

FanOutChan has one producer channel and multiple consumers for each message on the channel

func NewFanOutChan

func NewFanOutChan[T any]() *FanOutChan[T]

func (*FanOutChan[T]) Chan

func (f *FanOutChan[T]) Chan() chan T

func (*FanOutChan[T]) Close

func (f *FanOutChan[T]) Close()

func (*FanOutChan[T]) Listen

func (f *FanOutChan[T]) Listen() chan T

func (*FanOutChan[T]) StopListening

func (f *FanOutChan[T]) StopListening(ch chan T)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL