reserve

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	BinID        uint64
}

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,
	cb func(context.Context, internal.Storage, ...swarm.Address) error,
) (*Reserve, error)

func (*Reserve) AddSize

func (r *Reserve) AddSize(diff int)

func (*Reserve) Capacity

func (r *Reserve) Capacity() int

func (*Reserve) CleanupBinIndex

func (r *Reserve) CleanupBinIndex(
	ctx context.Context,
	batch storage.Batch,
	chunkAddress swarm.Address,
	binID uint64,
)

CleanupBinIndex removes the bin index entry for the chunk. This is called mainly to cleanup the bin index if other indexes are missing during reserve cleanup.

func (*Reserve) DeleteChunk

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

func (*Reserve) EvictBatchBin

func (r *Reserve) EvictBatchBin(
	ctx context.Context,
	txExecutor internal.TxExecutor,
	bin uint8,
	batchID []byte,
) (int, error)

EvictBatchBin evicts all chunks from bins upto the bin provided.

func (*Reserve) EvictionTarget

func (r *Reserve) EvictionTarget() int

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) 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