common

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

For key value stores where buckets are not supported, we add a byte to the key to represent a bucket. For now, all buckets are hard coded, but we could change that in the future.

Buckets are not really enough to index everything we wish to index. So we have labels as well. Labels are shifted 8 bits left, so they can be combined with the buckets to create a unique key.

This allows us to put the raw directory block at DBlockBucket+L_raw, and meta data about the directory block at DBlockBucket+MetaLabel

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesFixedUint64

func BytesFixedUint64(data []byte) (i uint64, nextData []byte)

BytesFixedUint64 Return a Uint64, for an 8 byte value,big endian (Note casting to an Int64 will work fine)

func BytesInt64

func BytesInt64(data []byte) (int64, []byte)

BytesInt64 Unmarshal a int64 (big endian) We only need this function on top of BytesUint64 to avoid a type conversion when dealing with int64 values

func BytesSlice

func BytesSlice(data []byte) (slice []byte, data2 []byte)

BytesSlice Convert a counted byte array (which is a count followed by the byte values) to a slice. We return what is left of the data once the counted byte array is removed

func BytesUint64

func BytesUint64(data []byte) (uint64, []byte)

BytesUint64 Unmarshal a uint64 (big endian)

func FormatTimeLapse

func FormatTimeLapse(d time.Duration) string

FormatTimeLapse Simple formatting for duration time. Prints all results within a fixed field of text.

func FormatTimeLapseSeconds

func FormatTimeLapseSeconds(total int64) string

DurationFormat Simple formatting if what I have is seconds. Prints all results within a fixed field of text.

func Int64Bytes

func Int64Bytes(i int64) []byte

Int64Bytes Marshal a int64 (big endian) We only need this function on top of Uint64Bytes to avoid a type conversion when dealing with int64 values

func SliceBytes

func SliceBytes(slice []byte) []byte

SliceBytes Append a Uvarint length infront of a slice, effectively converting a slice to a counted string

func TestReceipt_PrintChart

func TestReceipt_PrintChart(t *testing.T)

func Uint64Bytes

func Uint64Bytes(i uint64) (data []byte)

Uint64Bytes Marshal a uint64 (big endian)

func Uint64FixedBytes

func Uint64FixedBytes(i uint64) (data []byte)

Uint64FixedBytes Return []byte, big endian, of len 8 for the uint64 (Note casting an Int64 to uInt64 will give the same 8 bytes)

Types

type RandHash

type RandHash struct {
	List [][]byte
	// contains filtered or unexported fields
}

RandHash Creates a deterministic stream of hashes. We need this all over our tests and though this is late to the party, it is very useful in testing in SMT

func (*RandHash) GetAElement

func (n *RandHash) GetAElement(i int) (A [32]byte)

GetAElement Get an Array of an element out of the list of hashes

func (*RandHash) GetIntN added in v1.4.0

func (n *RandHash) GetIntN(N int) int

GetIntN Return an int between 0 and N

func (*RandHash) GetRandBuff

func (n *RandHash) GetRandBuff(size int) (buff []byte)

GetRandBuff return a buffer of random data of the given size. Okay, we could do this much more efficiently, but meh!

func (*RandHash) GetRandInt64

func (n *RandHash) GetRandInt64() int64

GetRandInt64 Really returns a 63 bit number, as the return value is always positive.

func (*RandHash) Next

func (n *RandHash) Next() []byte

Next Returns the next hash in a deterministic sequence of hashes

func (*RandHash) NextA

func (n *RandHash) NextA() (A [32]byte)

NextA Returns the next hash array in a deterministic sequence of hashes

func (*RandHash) NextAList

func (n *RandHash) NextAList() (A [32]byte)

NextAList Just like NextA, but each ash is logged in RandHash.ListA

func (*RandHash) NextList

func (n *RandHash) NextList() []byte

NextList Just like Next, but each hash is logged in RandHash.List

func (*RandHash) SetSeed

func (n *RandHash) SetSeed(seed []byte)

SetSeed If the tester wishes a different sequence of hashes, a seed can be specified

Jump to

Keyboard shortcuts

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