reserve

package
v2.2.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveChunkWithItem added in v2.1.0

func RemoveChunkWithItem(
	ctx context.Context,
	trx transaction.Store,
	item *BatchRadiusItem,
) error

Types

type BatchRadiusItem

type BatchRadiusItem struct {
	Bin       uint8
	BatchID   []byte
	StampHash []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

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

func (*BatchRadiusItem) ID

func (b *BatchRadiusItem) ID() string

batchID/bin/ChunkAddr/stampHash

func (*BatchRadiusItem) Marshal

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

func (*BatchRadiusItem) Namespace

func (b *BatchRadiusItem) Namespace() string

func (*BatchRadiusItem) String

func (b *BatchRadiusItem) String() string

func (*BatchRadiusItem) Unmarshal

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

type BatchRadiusItemV1 added in v2.2.0

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

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

func (*BatchRadiusItemV1) Clone added in v2.2.0

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

func (*BatchRadiusItemV1) ID added in v2.2.0

func (b *BatchRadiusItemV1) ID() string

func (*BatchRadiusItemV1) Marshal added in v2.2.0

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

func (*BatchRadiusItemV1) Namespace added in v2.2.0

func (b *BatchRadiusItemV1) Namespace() string

func (*BatchRadiusItemV1) String added in v2.2.0

func (b *BatchRadiusItemV1) String() string

func (*BatchRadiusItemV1) Unmarshal added in v2.2.0

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

type BinItem

type BinItem struct {
	Bin   uint8
	BinID uint64
}

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

func (*BinItem) Clone

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

func (*BinItem) ID

func (b *BinItem) ID() string

func (*BinItem) Marshal

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

func (*BinItem) Namespace

func (b *BinItem) Namespace() string

func (*BinItem) String

func (c *BinItem) String() string

func (*BinItem) Unmarshal

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

type ChunkBinItem

type ChunkBinItem struct {
	Bin       uint8
	BinID     uint64
	Address   swarm.Address
	BatchID   []byte
	StampHash []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

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

func (*ChunkBinItem) ID

func (c *ChunkBinItem) ID() string

bin/binID

func (*ChunkBinItem) Marshal

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

func (*ChunkBinItem) Namespace

func (c *ChunkBinItem) Namespace() string

func (*ChunkBinItem) String

func (c *ChunkBinItem) String() string

func (*ChunkBinItem) Unmarshal

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

type ChunkBinItemV1 added in v2.2.0

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

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

func (*ChunkBinItemV1) Clone added in v2.2.0

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

func (*ChunkBinItemV1) ID added in v2.2.0

func (c *ChunkBinItemV1) ID() string

func (*ChunkBinItemV1) Marshal added in v2.2.0

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

func (*ChunkBinItemV1) Namespace added in v2.2.0

func (c *ChunkBinItemV1) Namespace() string

func (*ChunkBinItemV1) String added in v2.2.0

func (c *ChunkBinItemV1) String() string

func (*ChunkBinItemV1) Unmarshal added in v2.2.0

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

type EpochItem

type EpochItem struct {
	Timestamp uint64
}

EpochItem stores the timestamp in seconds of the initial creation of the reserve.

func (*EpochItem) Clone

func (e *EpochItem) Clone() storage.Item

func (*EpochItem) ID

func (e *EpochItem) ID() string

func (*EpochItem) Marshal

func (e *EpochItem) Marshal() ([]byte, error)

func (*EpochItem) Namespace

func (e *EpochItem) Namespace() string

func (*EpochItem) String

func (e *EpochItem) String() string

func (*EpochItem) Unmarshal

func (e *EpochItem) Unmarshal(buf []byte) error

type Reserve

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

func New

func New(
	baseAddr swarm.Address,
	st transaction.Storage,
	capacity int,
	radiusSetter topology.SetStorageRadiuser,
	logger log.Logger,
) (*Reserve, error)

func (*Reserve) Capacity

func (r *Reserve) Capacity() int

func (*Reserve) EvictBatchBin

func (r *Reserve) EvictBatchBin(
	ctx context.Context,
	batchID []byte,
	count int,
	bin uint8,
) (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, addr swarm.Address, batchID []byte, stampHash []byte) (swarm.Chunk, error)

func (*Reserve) Has

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

func (*Reserve) IncBinID

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

func (*Reserve) IsWithinCapacity

func (r *Reserve) IsWithinCapacity() bool

func (*Reserve) IterateBin

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

func (*Reserve) IterateChunks

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

func (*Reserve) IterateChunksItems

func (r *Reserve) IterateChunksItems(startBin uint8, cb func(*ChunkBinItem) (bool, error)) error

func (*Reserve) LastBinIDs

func (r *Reserve) LastBinIDs() ([]uint64, uint64, error)

func (*Reserve) Put

func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) 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(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