utils

package
v0.0.0-...-4c6525d Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 11 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 ToFtm

func ToFtm(ftm uint64) *big.Int

ToFtm number of FTM 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 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