Documentation ¶
Overview ¶
Package bytesutil defines helper methods for converting integers to byte slices.
Index ¶
- func Bytes1(x uint64) []byte
- func Bytes2(x uint64) []byte
- func Bytes3(x uint64) []byte
- func Bytes32(x uint64) []byte
- func Bytes4(x uint64) []byte
- func Bytes8(x uint64) []byte
- func FromBytes4(x []byte) uint64
- func FromBytes8(x []byte) uint64
- func LowerThan(x []byte, y []byte) bool
- func ToBytes(x uint64, length int) []byte
- func ToBytes32(x []byte) [32]byte
- func ToBytes48(x []byte) [48]byte
- func ToBytes8(x []byte) [8]byte
- func ToBytes96(x []byte) [96]byte
- func ToLowInt64(x []byte) int64
- func Trunc(x []byte) []byte
- func Xor(x []byte, y []byte) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromBytes4 ¶
FromBytes4 returns an integer which is stored in the little-endian format(4, 'little') from a byte array.
func FromBytes8 ¶
FromBytes8 returns an integer which is stored in the little-endian format(8, 'little') from a byte array.
func LowerThan ¶
LowerThan returns true if byte slice x is lower than byte slice y. (little-endian format) This is used in spec to compare winning block root hash. Mentioned in spec as "ties broken by favoring lower `shard_block_root` values".
func ToBytes ¶
ToBytes returns integer x to bytes in little-endian format at the specified length. Spec pseudocode definition:
def int_to_bytes(integer: int, length: int) -> bytes: return integer.to_bytes(length, 'little')
func ToBytes32 ¶
ToBytes32 is a convenience method for converting a byte slice to a fix sized 32 byte array. This method will truncate the input if it is larger than 32 bytes.
func ToBytes48 ¶
ToBytes48 is a convenience method for converting a byte slice to a fix sized 48 byte array. This method will truncate the input if it is larger than 48 bytes.
func ToBytes8 ¶
ToBytes8 is a convenience method for converting a byte slice to a fix sized 8 byte array. This method will truncate the input if it is larger than 8 bytes.
func ToBytes96 ¶
ToBytes96 is a convenience method for converting a byte slice to a fix sized 96 byte array. This method will truncate the input if it is larger than 96 bytes.
func ToLowInt64 ¶
ToLowInt64 returns the lowest 8 bytes interpreted as little endian.
Types ¶
This section is empty.