utils

package
v0.15.3-patch.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendLongData

func AppendLongData(input []byte, data []byte) []byte

AppendLongData appends data shorter than 32MB

func AppendShortData

func AppendShortData(input []byte, data []byte) []byte

AppendShortData appends data shorter than 16kB

func AppendUint16

func AppendUint16(input []byte, value uint16) []byte

AppendUint16 appends the value bytes to the input slice (big endian)

func AppendUint32

func AppendUint32(input []byte, value uint32) []byte

AppendUint32 appends the value bytes to the input slice (big endian)

func AppendUint64

func AppendUint64(input []byte, value uint64) []byte

AppendUint64 appends the value bytes to the input slice (big endian)

func AppendUint8

func AppendUint8(input []byte, value uint8) []byte

AppendUint8 appends the value byte to the input slice

func Bit added in v0.14.5

func Bit(b []byte, idx int) int

Bit returns the bit at index `idx` in the byte array `b` (big endian)

The function assumes b has at least idx bits. The caller must make sure this condition is met.

func KeyPartFixture

func KeyPartFixture(typ uint16, val string) ledger.KeyPart

KeyPartFixture returns a key part fixture

func LightPayload

func LightPayload(key uint16, value uint16) *ledger.Payload

LightPayload returns a payload with 2 byte key and 2 byte value

func LightPayload8

func LightPayload8(key uint8, value uint8) *ledger.Payload

LightPayload8 returns a payload with 1 byte key and 1 byte value

func MaxUint16

func MaxUint16(a, b uint16) uint16

MaxUint16 returns the max value of two uint16

func PathByUint16 added in v0.14.5

func PathByUint16(inp uint16) ledger.Path

PathByUint16 returns a path (32 bytes) given a uint16 (big endian)

func PathByUint16LeftPadded added in v0.14.5

func PathByUint16LeftPadded(inp uint16) ledger.Path

PathByUint16LeftPadded returns a path (32 bytes) given a uint16 (left padded big endian)

func PathByUint8 added in v0.14.5

func PathByUint8(inp uint8) ledger.Path

PathByUint8 returns a path (32 bytes) given a uint8

func PathByUint8LeftPadded added in v0.14.5

func PathByUint8LeftPadded(inp uint8) ledger.Path

PathByUint8LeftPadded returns a path (32 bytes) given a uint8 (left padded)

func QueryFixture

func QueryFixture() *ledger.Query

QueryFixture returns a query fixture

func RandomPaths

func RandomPaths(n int, byteSize int) []ledger.Path

RandomPaths generates n random (no repetition) fixed sized (byteSize) paths

func RandomPathsRandLen

func RandomPathsRandLen(maxN int, byteSize int) []ledger.Path

RandomPathsRandLen generate m random paths (size: byteSize), the number of paths, m, is also randomly selected from the range [1, maxN]

func RandomPayload

func RandomPayload(minByteSize int, maxByteSize int) *ledger.Payload

RandomPayload returns a random payload

func RandomPayloads

func RandomPayloads(n int, minByteSize int, maxByteSize int) []*ledger.Payload

RandomPayloads returns n random payloads

func RandomUniqueKeys

func RandomUniqueKeys(n, m, minByteSize, maxByteSize int) []ledger.Key

RandomUniqueKeys generates n random keys (each with m random key parts)

func RandomUniqueKeysRandomN

func RandomUniqueKeysRandomN(maxN, m, minByteSize, maxByteSize int) []ledger.Key

RandomUniqueKeysRandomN generate n (0<n<maxN) random keys (each m random key part),

func RandomValues

func RandomValues(n int, minByteSize, maxByteSize int) []ledger.Value

RandomValues returns n random values with variable sizes (minByteSize <= size < maxByteSize)

func ReadFromBuffer

func ReadFromBuffer(reader io.Reader, length int) ([]byte, error)

ReadFromBuffer reads 'length' bytes from the input

func ReadLongData

func ReadLongData(input []byte) (data []byte, rest []byte, err error)

ReadLongData read data shorter than 32MB and return the rest of bytes

func ReadLongDataFromReader

func ReadLongDataFromReader(reader io.Reader) ([]byte, error)

ReadLongDataFromReader reads data shorter than 16kB from reader

func ReadShortData

func ReadShortData(input []byte) (data []byte, rest []byte, err error)

ReadShortData read data shorter than 16kB and return the rest of bytes

func ReadShortDataFromReader

func ReadShortDataFromReader(reader io.Reader) ([]byte, error)

ReadShortDataFromReader reads data shorter than 16kB from reader

func ReadSlice

func ReadSlice(input []byte, size int) (value []byte, rest []byte, err error)

ReadSlice reads `size` bytes from the input

func ReadUint16

func ReadUint16(input []byte) (value uint16, rest []byte, err error)

ReadUint16 reads a uint16 from the input and returns the rest

func ReadUint32

func ReadUint32(input []byte) (value uint32, rest []byte, err error)

ReadUint32 reads a uint32 from the input and returns the rest

func ReadUint64

func ReadUint64(input []byte) (value uint64, rest []byte, err error)

ReadUint64 reads a uint64 from the input and returns the rest

func ReadUint8

func ReadUint8(input []byte) (value uint8, rest []byte, err error)

ReadUint8 reads a uint8 from the input and returns the rest

func RootHashFixture

func RootHashFixture() ledger.RootHash

RootHashFixture returns a root hash fixture

func SetBit

func SetBit(b []byte, i int)

SetBit sets the bit at position i in the byte array b

The function assumes b has at least i bits. The caller must make sure this condition is met.

func SplitByPath

func SplitByPath(paths []ledger.Path, payloads []ledger.Payload, bitIndex int) ([]ledger.Path, []ledger.Payload, []ledger.Path, []ledger.Payload)

SplitByPath splits an slice of payloads based on the value of bit (bitIndex) of paths

func SplitSortedPaths

func SplitSortedPaths(paths []ledger.Path, bitIndex int) ([]ledger.Path, []ledger.Path)

SplitSortedPaths splits a set of ordered paths based on the value of bit (bitIndex)

func SplitTrieProofsByPath

func SplitTrieProofsByPath(paths []ledger.Path, proofs []*ledger.TrieProof, bitIndex int) ([]ledger.Path, []*ledger.TrieProof, []ledger.Path, []*ledger.TrieProof)

SplitTrieProofsByPath splits a set of unordered path and proof pairs based on the value of bit (bitIndex) of path

func TrieBatchProofFixture

func TrieBatchProofFixture() (*ledger.TrieBatchProof, ledger.State)

TrieBatchProofFixture returns a trie batch proof fixture

func TrieProofFixture

func TrieProofFixture() (*ledger.TrieProof, ledger.State)

TrieProofFixture returns a trie proof fixture

func Uint16ToBinary

func Uint16ToBinary(integer uint16) []byte

Uint16ToBinary converst a uint16 to a byte slice (big endian)

func Uint64ToBinary

func Uint64ToBinary(integer uint64) []byte

Uint64ToBinary converst a uint64 to a byte slice (big endian)

func UpdateFixture

func UpdateFixture() *ledger.Update

UpdateFixture returns an update fixture

Types

This section is empty.

Jump to

Keyboard shortcuts

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