reserve

package
v0.0.0-...-eb12069 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkItem

type ChunkItem struct {
	ChunkAddress swarm.Address
	BatchID      []byte
	Type         swarm.ChunkType
}

type Reserve

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

func New

func New(
	baseAddr swarm.Address,
	store storage.Store,
	capacity int,
	radiusSetter topology.SetStorageRadiuser,
	logger log.Logger) (*Reserve, error)

func (*Reserve) AddSize

func (r *Reserve) AddSize(diff int)

func (*Reserve) Capacity

func (r *Reserve) Capacity() int

func (*Reserve) DeleteChunk

func (r *Reserve) DeleteChunk(
	ctx context.Context,
	store internal.Storage,
	chunkAddress swarm.Address,
	batchID []byte,
) error

DeleteChunk is the exposed function to delete a chunk from the reserve.

func (*Reserve) Get

func (r *Reserve) Get(ctx context.Context, storage internal.Storage, addr swarm.Address, batchID []byte) (swarm.Chunk, error)

func (*Reserve) Has

func (r *Reserve) Has(store storage.Store, addr swarm.Address, batchID []byte) (bool, error)

func (*Reserve) IsWithinCapacity

func (r *Reserve) IsWithinCapacity() bool

func (*Reserve) IterateBatchBin

func (r *Reserve) IterateBatchBin(
	ctx context.Context,
	store internal.Storage,
	bin uint8,
	batchID []byte,
	cb func(swarm.Address) (bool, error),
) error

IterateBatchBin iterates over all chunks pertaining to the batch in the particular bin. The callback function should return true to stop the iteration.

func (*Reserve) IterateBin

func (r *Reserve) IterateBin(store storage.Store, bin uint8, startBinID uint64, cb func(swarm.Address, uint64, []byte) (bool, error)) error

func (*Reserve) IterateChunks

func (r *Reserve) IterateChunks(store internal.Storage, startBin uint8, cb func(swarm.Chunk) (bool, error)) error

func (*Reserve) IterateChunksItems

func (r *Reserve) IterateChunksItems(store internal.Storage, startBin uint8, cb func(ChunkItem) (bool, error)) error

func (*Reserve) LastBinIDs

func (r *Reserve) LastBinIDs(store storage.Store) ([]uint64, error)

func (*Reserve) Put

func (r *Reserve) Put(ctx context.Context, store internal.Storage, chunk swarm.Chunk) (bool, error)

Put stores a new chunk in the reserve and returns if the reserve size should increase.

func (*Reserve) Radius

func (r *Reserve) Radius() uint8

func (*Reserve) SetRadius

func (r *Reserve) SetRadius(store storage.Store, rad uint8) error

func (*Reserve) Size

func (r *Reserve) Size() int

Jump to

Keyboard shortcuts

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