utils

package
v0.0.0-...-34d0e24 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigTo256

func BigTo256(b *big.Int) common.Hash

BigTo256 converts big number to 32 bytes array

func I64to256

func I64to256(i64 int64) common.Hash

I64to256 converts int64 to 32 bytes array

func NameOf

func NameOf(p idx.ValidatorID) string

NameOf returns human readable string representation.

func ToVolary

func ToVolary(vlry uint64) *big.Int

ToVolary number of vlry to Wei

func U64to256

func U64to256(u64 uint64) common.Hash

U64to256 converts uint64 to 32 bytes array

func U64toBig

func U64toBig(u64 uint64) *big.Int

U64toBig converts uint64 to big number

func WeightedPermutation

func WeightedPermutation(size int, weights []pos.Weight, seed hash.Hash) []int

WeightedPermutation builds weighted random permutation Returns first {size} entries of {weights} permutation. Call with {size} == len(weights) to get the whole permutation.

Types

type NumQueue

type NumQueue struct {
	// contains filtered or unexported fields
}

func NewNumQueue

func NewNumQueue(init uint64) *NumQueue

func (*NumQueue) Done

func (q *NumQueue) Done(n uint64)

func (*NumQueue) WaitFor

func (q *NumQueue) WaitFor(n uint64)

type PrettyDuration

type PrettyDuration time.Duration

PrettyDuration is a combination of common.PrettyDuration and common.PrettyAge It is a pretty printed version of a time.Duration value that rounds the values up to a single most significant unit, while showing the least significant part if duration isn't too large.

func (PrettyDuration) String

func (t PrettyDuration) String() string

String implements the Stringer interface, allowing pretty printing of duration values rounded to the most significant time unit.

type SpinLock

type SpinLock struct {
	// contains filtered or unexported fields
}

SpinLock implements a simple atomic spin lock, the zero value for a SpinLock is an unlocked spinlock.

func (*SpinLock) Lock

func (sl *SpinLock) Lock()

Lock locks sl. If the lock is already in use, the caller blocks until Unlock is called

func (*SpinLock) String

func (sl *SpinLock) String() string

String is human readable lock state

func (*SpinLock) TryLock

func (sl *SpinLock) TryLock() bool

TryLock will try to lock sl and return whether it succeed or not without blocking.

func (*SpinLock) Unlock

func (sl *SpinLock) Unlock()

Unlock unlocks sl, unlike [Mutex.Unlock](http://golang.org/pkg/sync/#Mutex.Unlock), there's no harm calling it on an unlocked SpinLock

Jump to

Keyboard shortcuts

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