util

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 2^35 - 1
	PackedAmountMaxMantissa = big.NewInt(34359738367)
	// 2^11 - 1
	PackedFeeMaxMantissa  = big.NewInt(2047)
	PackedAmountMaxAmount = ffmath.Multiply(big.NewInt(34359738367), new(big.Int).Exp(big.NewInt(10), big.NewInt(31), nil))
	PackedFeeMaxAmount    = ffmath.Multiply(big.NewInt(2047), new(big.Int).Exp(big.NewInt(10), big.NewInt(31), nil))
	ZeroBigInt            = big.NewInt(0)
)

Functions

func CleanPackedAmount

func CleanPackedAmount(amount *big.Int) (nAmount *big.Int, err error)

func CleanPackedFee

func CleanPackedFee(amount *big.Int) (nAmount *big.Int, err error)

func HashToInt

func HashToInt(b bytes.Buffer, h hash.Hash) (*big.Int, error)

func ToPackedAmount

func ToPackedAmount(amount *big.Int) (res int64, err error)

ToPackedAmount: convert big int to 40 bit, 5 bits for 10^x, 35 bits for a * 10^x

func ToPackedFee

func ToPackedFee(amount *big.Int) (res int64, err error)

ToPackedFee: convert big int to 16 bit, 5 bits for 10^x, 11 bits for a * 10^x

Types

This section is empty.

Jump to

Keyboard shortcuts

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