Documentation
¶
Overview ¶
Package common contains various helper functions.
Index ¶
- Variables
- func AllZero(b []byte) bool
- func BigUint64(v *big.Int) (uint64, bool)
- func Bytes2Hex(d []byte) string
- func CalcMemSize(off, l *big.Int) *big.Int
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) []byte
- func GetData(data []byte, start uint64, size uint64) []byte
- func GetDataBig(data []byte, start *big.Int, size *big.Int) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) stringdeprecated
- func ToHexArray(b [][]byte) []string
- func ToWordSize(size uint64) uint64
- type StorageSize
Constants ¶
This section is empty.
Variables ¶
var ( Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big0 = big.NewInt(0) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) )
Common big integers often used
Functions ¶
func BigUint64 ¶
bigUint64 returns the integer casted to a uint64 and returns whether it overflowed in the process.
func CalcMemSize ¶
calculates the memory size required for a step
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetData ¶
getData returns a slice from the data based on the start and size and pads up to size with zero's. This function is overflow safe.
func GetDataBig ¶
getDataBig returns a slice from the data based on the start and size and pads up to size with zero's. This function is overflow safe.
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func ToHexArray ¶
ToHexArray creates a array of hex-string based on []byte
func ToWordSize ¶
toWordSize returns the ceiled word size required for memory expansion.
Types ¶
type StorageSize ¶
type StorageSize float64
StorageSize is a wrapper around a float value that supports user friendly formatting.
func (StorageSize) String ¶
func (s StorageSize) String() string
String implements the stringer interface.
func (StorageSize) TerminalString ¶
func (s StorageSize) TerminalString() string
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.