fixtures

package
v0.0.0-...-ee0e00b Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BLOCK_ID_SIZE = 32

Variables

This section is empty.

Functions

func RandBool

func RandBool(p float64) bool

func XX3HashBlockId

func XX3HashBlockId(id BlockId, seed uint64) uint64

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block

func NewBlock

func NewBlock(id BlockId, size int64) *Block

func RandMockBlock

func RandMockBlock() *Block

Generate a random block up to 10k bytes in length Does not allocate memory for the byte array

func (*Block) AddChild

func (b *Block) AddChild(id BlockId) error

func (*Block) Children

func (b *Block) Children() []BlockId

func (*Block) Id

func (b *Block) Id() BlockId

func (*Block) RawData

func (b *Block) RawData() []byte

func (*Block) Size

func (b *Block) Size() int64

type BlockId

type BlockId [BLOCK_ID_SIZE]byte

Defines a simple block 256-bit BlockId

func AddRandomForest

func AddRandomForest(ctx context.Context, store *Store, rootCount int) []BlockId

func AddRandomTree

func AddRandomTree(ctx context.Context, store *Store, maxChildren int, maxDepth int, pCrosslink float64) BlockId

func RandId

func RandId() BlockId

Generate a random block Id

func (BlockId) MarshalBinary

func (id BlockId) MarshalBinary() ([]byte, error)

Gets the data for this block as a byte array

func (BlockId) MarshalCBOR

func (id BlockId) MarshalCBOR() ([]byte, error)

func (BlockId) MarshalJSON

func (id BlockId) MarshalJSON() ([]byte, error)

func (*BlockId) Read

func (id *BlockId) Read(reader core.ByteAndBlockReader) (int, error)

func (BlockId) String

func (id BlockId) String() string

Returns a URL-encoded base 64 string

func (*BlockId) UnmarshalBinary

func (id *BlockId) UnmarshalBinary(bytes []byte) error

func (*BlockId) UnmarshalCBOR

func (id *BlockId) UnmarshalCBOR(bytes []byte) error

func (*BlockId) UnmarshalJSON

func (id *BlockId) UnmarshalJSON(bytes []byte) error

type Config

type Config struct {
	WriteStorageLatency  time.Duration
	WriteStorageBandwith time.Duration // time to write one byte
	ReadStorageLatency   time.Duration
	ReadStorageBandwith  time.Duration // time to write one byte
}

func DefaultConfig

func DefaultConfig() Config

type MockIdJsonFormat

type MockIdJsonFormat struct {
	Id []byte `json:"id"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

BlockStore

func NewStore

func NewStore(config Config) *Store

func (*Store) Add

func (bs *Store) Add(_ context.Context, rawBlock core.RawBlock[BlockId]) (core.Block[BlockId], error)

func (*Store) AddAll

func (bs *Store) AddAll(ctx context.Context, store core.BlockStore[BlockId]) error

func (*Store) AddMany

func (bs *Store) AddMany(_ context.Context, rawBlocks []core.RawBlock[BlockId]) ([]core.Block[BlockId], error)

func (*Store) All

func (bs *Store) All(_ context.Context) (<-chan BlockId, error)

func (*Store) Dump

func (bs *Store) Dump(id BlockId, log *zap.SugaredLogger, spacer string) (core.Block[BlockId], error)

func (*Store) Get

func (bs *Store) Get(_ context.Context, id BlockId) (core.Block[BlockId], error)

func (*Store) Has

func (bs *Store) Has(_ context.Context, id BlockId) (bool, error)

func (*Store) HasAll

func (bs *Store) HasAll(root BlockId) bool

func (*Store) RandomBlock

func (bs *Store) RandomBlock() (core.Block[BlockId], error)

func (*Store) Reconfigure

func (bs *Store) Reconfigure(config Config)

func (*Store) Remove

func (bs *Store) Remove(id BlockId)

Jump to

Keyboard shortcuts

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