reserve

package
v1.17.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkType added in v1.17.2

func ChunkType(ch swarm.Chunk) swarm.ChunkType

Types

type BatchRadiusItem added in v1.17.2

type BatchRadiusItem struct {
	Bin     uint8
	BatchID []byte
	Address swarm.Address
	BinID   uint64
}

BatchRadiusItem allows iteration of the chunks with respect to bin and batchID. Used for batch evictions of certain bins.

func (*BatchRadiusItem) Clone added in v1.17.2

func (b *BatchRadiusItem) Clone() storage.Item

func (*BatchRadiusItem) ID added in v1.17.2

func (b *BatchRadiusItem) ID() string

batchID/bin/ChunkAddr

func (*BatchRadiusItem) Marshal added in v1.17.2

func (b *BatchRadiusItem) Marshal() ([]byte, error)

func (*BatchRadiusItem) Namespace added in v1.17.2

func (b *BatchRadiusItem) Namespace() string

func (*BatchRadiusItem) String added in v1.17.2

func (b *BatchRadiusItem) String() string

func (*BatchRadiusItem) Unmarshal added in v1.17.2

func (b *BatchRadiusItem) Unmarshal(buf []byte) error

type BinItem added in v1.17.2

type BinItem struct {
	Bin   uint8
	BinID uint64
}

BinItem stores the latest binIDs for each bin between 0 and swarm.MaxBins

func (*BinItem) Clone added in v1.17.2

func (b *BinItem) Clone() storage.Item

func (*BinItem) ID added in v1.17.2

func (b *BinItem) ID() string

func (*BinItem) Marshal added in v1.17.2

func (c *BinItem) Marshal() ([]byte, error)

func (*BinItem) Namespace added in v1.17.2

func (b *BinItem) Namespace() string

func (*BinItem) String added in v1.17.2

func (c *BinItem) String() string

func (*BinItem) Unmarshal added in v1.17.2

func (c *BinItem) Unmarshal(buf []byte) error

type ChunkBinItem added in v1.17.2

type ChunkBinItem struct {
	Bin       uint8
	BinID     uint64
	Address   swarm.Address
	BatchID   []byte
	ChunkType swarm.ChunkType
}

ChunkBinItem allows for iterating on ranges of bin and binIDs for chunks. BinIDs come in handy when syncing the reserve contents with other peers.

func (*ChunkBinItem) Clone added in v1.17.2

func (c *ChunkBinItem) Clone() storage.Item

func (*ChunkBinItem) ID added in v1.17.2

func (c *ChunkBinItem) ID() string

bin/binID

func (*ChunkBinItem) Marshal added in v1.17.2

func (c *ChunkBinItem) Marshal() ([]byte, error)

func (*ChunkBinItem) Namespace added in v1.17.2

func (c *ChunkBinItem) Namespace() string

func (*ChunkBinItem) String added in v1.17.2

func (c *ChunkBinItem) String() string

func (*ChunkBinItem) Unmarshal added in v1.17.2

func (c *ChunkBinItem) Unmarshal(buf []byte) error

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) IncBinID added in v1.17.2

func (r *Reserve) IncBinID(store storage.Store, bin uint8) (uint64, error)

should be called under lock

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