Documentation ¶
Index ¶
- Variables
- func ChunkType(ch swarm.Chunk) swarm.ChunkType
- func IdentityAddress(chunk swarm.Chunk) (swarm.Address, error)
- type Batch
- type BatchStore
- type Batcher
- type ChunkGetterDeleter
- type ChunkState
- type ChunkStore
- type Cloner
- type Deleter
- type Descriptor
- type Filter
- type Getter
- type GetterFunc
- type Hasser
- type IndexStore
- type Item
- type IterateChunkFn
- type IterateFn
- type Key
- type Marshaler
- type Order
- type PullSubscriber
- type PushReporter
- type PushSubscriber
- type Putter
- type PutterFunc
- type Query
- type QueryItemProperty
- type ReadOnlyChunkStore
- type Reader
- type Recoverer
- type Replacer
- type Result
- type Sharky
- type SizeReporter
- type StateIterFunc
- type StateStorer
- type StateStorerCleaner
- type StateStorerManager
- type Store
- type Unmarshaler
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrOverwriteNewerChunk = errors.New("overwriting chunk with newer timestamp") ErrUnknownChunkType = errors.New("unknown chunk type") )
var ( ErrInvalidQuery = errors.New("storage: invalid query") ErrNotFound = errors.New("storage: not found") ErrReferenceLength = errors.New("storage: invalid reference length") ErrInvalidChunk = errors.New("storage: invalid chunk") )
ErrInvalidQuery indicates that the query is not a valid query.
var ErrBatchCommitted = errors.New("storage: batch has already been committed")
ErrBatchCommitted is returned by Batch.Commit call when a batch has already been committed.
Functions ¶
func IdentityAddress ¶
IdentityAddress returns the internally used address for the chunk since the single owner chunk address is not a unique identifier for the chunk, but hashing the soc address and the wrapped chunk address is. it is used in the reserve sampling and other places where a key is needed to represent a chunk.
Types ¶
type Batch ¶
type Batch interface { // Put adds a new item to the batch. Put(Item) error // Delete adds a new delete operation to the batch. Delete(Item) error // Commit commits the batch. Commit() error }
Batch provides set of operations that are batched.
type BatchStore ¶ added in v2.1.0
BatchStore is a store that supports batching of Writer method calls.
type ChunkGetterDeleter ¶
ChunkGetterDeleter is a storage that provides only read and delete operations for chunks.
type ChunkState ¶
type ChunkState = int
const ( // ChunkSent is used by the pusher component to notify about successful push of chunk from // the node. A chunk could be retried on failure so, this sent count is maintained to // understand how many attempts were made by the node while pushing. The attempts are // registered only when an actual request was sent from this node. ChunkSent ChunkState = iota // ChunkStored is used by the pusher component to notify that the uploader node is // the closest node and has stored the chunk. ChunkStored // ChunkSynced is used by the pusher component to notify that the chunk is synced to the // network. This is reported when a valid receipt was received after the chunk was // pushed. ChunkSynced ChunkCouldNotSync )
type ChunkStore ¶
type Deleter ¶
type Deleter interface { // Delete a chunk by the given swarm.Address. Delete(context.Context, swarm.Address) error }
Deleter is the interface that wraps the basic Delete method.
type Descriptor ¶
Descriptor holds information required for Pull syncing. This struct is provided by subscribing to pull index.
func (*Descriptor) String ¶
func (d *Descriptor) String() string
type Filter ¶
Filter subtracts entries from the iteration. Filters would not construct the Item from the serialized bytes. Instead, users can add logic to check the entries directly in byte format or partially or fully unmarshal the data and check.
type Getter ¶
type Getter interface { // Get a chunk by its swarm.Address. Returns the chunk associated with // the address alongside with its postage stamp, or a storage.ErrNotFound // if the chunk is not found. // If the chunk has multiple stamps, then the first stamp is returned in this // query. In order to deterministically get the stamp, use the GetterWithStamp // interface. If the chunk is not found storage.ErrNotFound will be returned. Get(context.Context, swarm.Address) (swarm.Chunk, error) }
Getter is the interface that wraps the basic Get method.
type GetterFunc ¶
type Hasser ¶
type Hasser interface { // Has checks whether a chunk exists in the store. Has(context.Context, swarm.Address) (bool, error) }
Hasser is the interface that wraps the basic Has method.
type IndexStore ¶ added in v2.1.0
type IterateFn ¶
IterateFn iterates through the Items of the store in the Key.Namespace. The function returns a boolean to indicate if the iteration should stop.
type Key ¶
type Key interface { // ID is the unique identifier of Item. ID() string // Namespace is used to separate similar items. // E.g.: can be seen as a table construct. Namespace() string }
Key represents the item identifiers.
type Marshaler ¶
Marshaler is the interface implemented by types that can marshal themselves into valid Item.
type PullSubscriber ¶
type PullSubscriber interface {
SubscribePull(ctx context.Context, bin uint8, since, until uint64) (c <-chan Descriptor, closed <-chan struct{}, stop func())
}
type PushReporter ¶
PushReporter is used to report chunk state.
type PushSubscriber ¶
type Putter ¶
type Putter interface { // Put a chunk into the store alongside with its postage stamp. Put(context.Context, swarm.Chunk) error }
Putter is the interface that wraps the basic Put method.
type PutterFunc ¶
PutterFunc type is an adapter to allow the use of ChunkStore as Putter interface. If f is a function with the appropriate signature, PutterFunc(f) is a Putter that calls f.
type Query ¶
type Query struct { // Factory is a constructor passed by client // to construct new object for the result. Factory func() Item // Prefix indicates interest in an item // that contains this prefix in its ID. Prefix string // PrefixAtStart indicates that the // iteration should start at the prefix. PrefixAtStart bool // SkipFirst skips the first element in the iteration. SkipFirst bool // ItemProperty indicates a specific interest of an Item property. ItemProperty QueryItemProperty // Order denotes the order of iteration. Order Order // Filters represent further constraints on the iteration. Filters []Filter }
Query denotes the iteration attributes.
type QueryItemProperty ¶
type QueryItemProperty int
QueryItemProperty tells the Query which Item property should be loaded from the store to the result.
const ( // QueryItem indicates interest in the whole Item. QueryItem QueryItemProperty = iota // QueryItemID indicates interest in the Result.ID. // No data will be unmarshalled. QueryItemID // QueryItemSize indicates interest in the Result.Size. // No data will be unmarshalled. QueryItemSize )
type ReadOnlyChunkStore ¶
type Reader ¶
type Reader interface { // Get unmarshalls object with the given Item.Key.ID into the given Item. Get(Item) error // Has reports whether the Item with the given Key.ID exists in the store. Has(Key) (bool, error) // GetSize returns the size of Item with the given Key.ID. GetSize(Key) (int, error) // Iterate executes the given IterateFn on this store. // The Result of the iteration will be affected by the given Query. Iterate(Query, IterateFn) error // Count returns the count of items in the // store that are in the same Key.Namespace. Count(Key) (int, error) }
Reader groups methods that read from the store.
type Recoverer ¶
type Recoverer interface {
Recover() error
}
Recoverer allows store to recover from a failure when the transaction was not committed or rolled back.
type Replacer ¶ added in v2.2.0
type Replacer interface { // Replace a chunk in the store. Replace(context.Context, swarm.Chunk, bool) error }
Replacer is the interface that wraps the basic Replace method.
type Result ¶
type Result struct { // ID is the Key.ID of the result Item. ID string // Size is the size of the result Item. Size int // Entry in the result Item. Entry Item }
Result represents the item returned by the read operation, which returns the item as the result. Or Key and/or Size in case the whole Item is not needed.
type SizeReporter ¶
type StateIterFunc ¶
StateIterFunc is used when iterating through StateStorer key/value pairs
type StateStorer ¶
type StateStorer interface { io.Closer // Get unmarshalls object with the given key into the given obj. Get(key string, obj interface{}) error // Put inserts or updates the given obj stored under the given key. Put(key string, obj interface{}) error // Delete removes object form the store stored under the given key. Delete(key string) error // Iterate iterates over all keys with the given prefix and calls iterFunc. Iterate(prefix string, iterFunc StateIterFunc) error }
StateStorer is a storage interface for storing and retrieving key/value pairs.
type StateStorerCleaner ¶
type StateStorerCleaner interface { // Nuke the store so that only the bare essential entries are left. Nuke() error // ClearForHopping removes all data not required in a new neighborhood ClearForHopping() error }
StateStorerCleaner is the interface for cleaning the store.
type StateStorerManager ¶ added in v2.2.0
type StateStorerManager interface { StateStorer StateStorerCleaner }
StateStorerManager defines all external methods of the state storage
type Unmarshaler ¶
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves. The input can be assumed to be a valid encoding of a Item value.
type Writer ¶
type Writer interface { // Put inserts or updates the given Item identified by its Key.ID. Put(Item) error // Delete removes the given Item form the store. // It will not return error if the key doesn't exist. Delete(Item) error }
Writer groups methods that change the state of the store.