Documentation ¶
Index ¶
- func RemoveChunkWithItem(ctx context.Context, trx transaction.Store, item *BatchRadiusItem) error
- type BatchRadiusItem
- type BatchRadiusItemV1
- type BinItem
- type ChunkBinItem
- type ChunkBinItemV1
- type EpochItem
- type Reserve
- func (r *Reserve) Capacity() int
- func (r *Reserve) EvictBatchBin(ctx context.Context, batchID []byte, count int, bin uint8) (int, error)
- func (r *Reserve) EvictionTarget() int
- func (r *Reserve) Get(ctx context.Context, addr swarm.Address, batchID []byte, stampHash []byte) (swarm.Chunk, error)
- func (r *Reserve) Has(addr swarm.Address, batchID []byte, stampHash []byte) (bool, error)
- func (r *Reserve) IncBinID(store storage.IndexStore, bin uint8) (uint64, error)
- func (r *Reserve) IsWithinCapacity() bool
- func (r *Reserve) IterateBin(bin uint8, startBinID uint64, ...) error
- func (r *Reserve) IterateChunks(startBin uint8, cb func(swarm.Chunk) (bool, error)) error
- func (r *Reserve) IterateChunksItems(startBin uint8, cb func(*ChunkBinItem) (bool, error)) error
- func (r *Reserve) LastBinIDs() ([]uint64, uint64, error)
- func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error
- func (r *Reserve) Radius() uint8
- func (r *Reserve) Reset(ctx context.Context) error
- func (r *Reserve) SetRadius(rad uint8) error
- func (r *Reserve) Size() int
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) 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
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 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) 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.
type Reserve ¶
type Reserve struct {
// contains filtered or unexported fields
}
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 (*Reserve) IsWithinCapacity ¶
func (*Reserve) IterateBin ¶
func (*Reserve) IterateChunks ¶
func (*Reserve) IterateChunksItems ¶
func (*Reserve) Put ¶
Reserve Put has to handle multiple possible scenarios.
- Since the same chunk may belong to different postage stamp indices, the reserve will support one chunk to many postage stamp indices relationship.
- A new chunk that shares the same stamp index belonging to the same batch with an already stored chunk will overwrite the existing chunk if the new chunk has a higher stamp timestamp (regardless of batch type).
- A new chunk that has the same address belonging to the same stamp index with an already stored chunk will overwrite the existing chunk if the new chunk has a higher stamp timestamp (regardless of batch type and chunk type, eg CAC & SOC).