utility

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MetachainShardName = "metachain"

MetachainShardName is the string identifier of the metachain shard

Variables

This section is empty.

Functions

func GetAddressOrMetachainAddr

func GetAddressOrMetachainAddr(address string) []byte

GetAddressOrMetachainAddr checks if the corresponding address is metachain. This func should only be used for sender addresses. If so, it returns a 62 byte array address(by padding with zeros), otherwise converts the address string to byte slice.

func GetBigIntBytesFromStr

func GetBigIntBytesFromStr(val string) ([]byte, error)

GetBigIntBytesFromStr returns the big int bytes representation of a string input if not empty, otherwise returns []byte{}

func GetBigIntBytesSliceFromStringSlice

func GetBigIntBytesSliceFromStringSlice(in []string) ([][]byte, error)

GetBigIntBytesSliceFromStringSlice converts the input string slice in a big int byte array slice

func GetBytes

func GetBytes(val *big.Int) []byte

GetBytes returns the bytes representation of a big int input if not nil, otherwise returns []byte{}

func MetaChainShardAddress

func MetaChainShardAddress() []byte

MetaChainShardAddress returns core.MetachainShardId as a 62 byte array address(by padding with zeros). This is needed, since all addresses from avro schema are required to be 62 fixed byte array

func StringSliceToByteSlice

func StringSliceToByteSlice(in []string) [][]byte

StringSliceToByteSlice converts the input string slice to a byte slice

func UInt32SliceToInt32Slice

func UInt32SliceToInt32Slice(in []uint32) []int32

UInt32SliceToInt32Slice outputs the int32 slice representation of a uint32 slice input

func UIntSliceToIntSlice

func UIntSliceToIntSlice(in []uint64) []int64

UIntSliceToIntSlice outputs the int64 slice representation of a uint64 slice input

Types

type AvroMarshaller

type AvroMarshaller struct {
}

AvroMarshaller can marshall/unmarshall avro records

func (*AvroMarshaller) Decode

func (av *AvroMarshaller) Decode(record avro.AvroRecord, buffer []byte) error

Decode tries to decode a data buffer, read it and store it on the input record. If successfully, the record is filled with data from the buffer, otherwise an error might be returned

func (*AvroMarshaller) Encode

func (av *AvroMarshaller) Encode(record avro.AvroRecord) ([]byte, error)

Encode returns a byte slice representing the binary encoding of the input avro record

Jump to

Keyboard shortcuts

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