util

package
v0.0.0-...-b221635 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ZeroInt is the default value for a big.Int.
	ZeroInt = new(big.Int).SetInt64(0)

	// ZeroRat is the default value for a big.Rat.
	ZeroRat = new(big.Rat).SetInt64(0)

	// KiloHash is 1 KH represented as a big.Rat.
	KiloHash = new(big.Rat).SetInt64(1000)

	// MegaHash is 1MH represented as a big.Rat.
	MegaHash = new(big.Rat).SetInt64(1000000)

	// GigaHash is 1GH represented as a big.Rat.
	GigaHash = new(big.Rat).SetInt64(1000000000)

	// TeraHash is 1TH represented as a big.Rat.
	TeraHash = new(big.Rat).SetInt64(1000000000000)

	// PetaHash is 1PH represented as a big.Rat
	PetaHash = new(big.Rat).SetInt64(1000000000000000)
)

Functions

func BigEndianBytesToHeight

func BigEndianBytesToHeight(b []byte) uint32

BigEndianBytesToHeight returns the block height of the provided 4-byte big endian representation.

func BigEndianBytesToNano

func BigEndianBytesToNano(b []byte) int64

BigEndianBytesToNano returns nanosecond time of the provided 8-byte big endian representation.

func BigEndianBytesToTime

func BigEndianBytesToTime(b []byte) *time.Time

BigEndianBytesToTime returns a time instance of the provided 8-byte big endian representation.

func BigToLEUint256

func BigToLEUint256(n *big.Int) [uint256Size]byte

BigToLEUint256 returns the passed big integer as an unsigned 256-bit integer encoded as little-endian bytes. Numbers which are larger than the max unsigned 256-bit integer are truncated.

func CleanAndExpandPath

func CleanAndExpandPath(path string) string

CleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it.

func HashString

func HashString(hash *big.Rat) string

HashString formats the provided hashrate per the best-fit unit.

func HeightToBigEndianBytes

func HeightToBigEndianBytes(height uint32) []byte

HeightToBigEndianBytes returns an 4-byte big endian representation of the provided block height.

func HexReversed

func HexReversed(in string) (string, error)

HexReversed reverses a hex string.

func LEUint256ToBig

func LEUint256ToBig(n [uint256Size]byte) *big.Int

LEUint256ToBig returns the passed unsigned 256-bit integer encoded as little-endian as a big integer.

func NanoToBigEndianBytes

func NanoToBigEndianBytes(nano int64) []byte

NanoToBigEndianBytes returns an 8-byte big endian representation of the provided nanosecond time.

func ReversePrevBlockWords

func ReversePrevBlockWords(hashE string) string

ReversePrevBlockWords reverses each 4-byte word in the provided hex encoded previous block hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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