Documentation ¶
Index ¶
- Constants
- func WithBaseDir(baseDir string) options.Option[Manager]
- func WithDBProvider(provider DBProvider) options.Option[Manager]
- func WithGranularity(granularity int64) options.Option[Manager]
- func WithMaxOpenDBs(optsMaxOpenDBs int) options.Option[Manager]
- type CacheTimeProvider
- type DB
- type DBProvider
- type IndexedKey
- type Manager
- func (m *Manager) Flush(index slot.Index)
- func (m *Manager) Get(index slot.Index, realm kvstore.Realm) kvstore.KVStore
- func (m *Manager) IsTooOld(index slot.Index) (isTooOld bool)
- func (m *Manager) MaxPrunedSlot() slot.Index
- func (m *Manager) PermanentStorage() kvstore.KVStore
- func (m *Manager) PermanentStorageSize() int64
- func (m *Manager) PrunableStorageSize() int64
- func (m *Manager) PruneUntilSlot(index slot.Index)
- func (m *Manager) RestoreFromDisk() (latestBucketIndex slot.Index)
- func (m *Manager) Shutdown()
- func (m *Manager) TotalStorageSize() int64
- type PersistentSlotStorage
- func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Delete(key K) (success bool)
- func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Get(key K) (value V, exists bool)
- func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Iterate(index slot.Index, callback func(key K, value V) (advance bool), ...) (err error)
- func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Set(key K, value V) (err error)
- type Version
Constants ¶
const ( // PrefixPeer defines the prefix of the peer db. PrefixPeer byte = iota // PrefixLedger defines the storage prefix for the ledger package. PrefixLedger // PrefixIndexer defines the storage prefix for the indexer package. PrefixIndexer )
Variables ¶
This section is empty.
Functions ¶
func WithBaseDir ¶
WithBaseDir sets the base directory to store the DB to disk.
func WithDBProvider ¶
func WithDBProvider(provider DBProvider) options.Option[Manager]
WithDBProvider sets the DB provider that is used to create new DB instances.
func WithGranularity ¶
WithGranularity sets the granularity of the DB instances (i.e. how many buckets/slots are stored in one DB). It thus also has an impact on how fine-grained buckets/slots can be pruned.
Types ¶
type CacheTimeProvider ¶
type CacheTimeProvider struct {
// contains filtered or unexported fields
}
CacheTimeProvider should be always used to get the CacheTime option for storage It wraps around objectstorage.CacheTime() function and may override the input duration.
func NewCacheTimeProvider ¶
func NewCacheTimeProvider(forceCacheTime time.Duration) *CacheTimeProvider
NewCacheTimeProvider creates an instance that forces cache time to always be a certain value. If the given value is negative, hard coded defaults will be used.
func (*CacheTimeProvider) CacheTime ¶
func (m *CacheTimeProvider) CacheTime(duration time.Duration) objectstorage.Option
CacheTime returns a CacheTime option. Duration may be overridden if CacheTimeProvider parameter is a non-negative integer.
type DB ¶
type DB interface { // NewStore creates a new KVStore backed by the database. NewStore() kvstore.KVStore // Close closes a DB. Close() error // RequiresGC returns whether the database requires a call of GC() to clean deleted items. RequiresGC() bool // GC runs the garbage collection to clean deleted database items. GC() error }
DB represents a database abstraction.
type DBProvider ¶
DBProvider is a function that creates a new DB instance.
type IndexedKey ¶
type IndexedKey[A any] interface { slot.IndexedID serializer.MarshalablePtr[A] }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) IsTooOld ¶
IsTooOld checks if the Block associated with the given id is too old (in a pruned slot).
func (*Manager) MaxPrunedSlot ¶
func (*Manager) PermanentStorage ¶
func (*Manager) PermanentStorageSize ¶
PermanentStorageSize returns the size of the permanent storage.
func (*Manager) PrunableStorageSize ¶
PrunableStorageSize returns the size of the prunable storage containing all db instances.
func (*Manager) PruneUntilSlot ¶
func (*Manager) RestoreFromDisk ¶
func (*Manager) TotalStorageSize ¶
TotalStorageSize returns the combined size of the permanent and prunable storage.
type PersistentSlotStorage ¶
type PersistentSlotStorage[K, V any, KPtr IndexedKey[K], VPtr serializer.MarshalablePtr[V]] struct { // contains filtered or unexported fields }
func NewPersistentSlotStorage ¶
func NewPersistentSlotStorage[K, V any, KPtr IndexedKey[K], VPtr serializer.MarshalablePtr[V]](dbManager *Manager, realm kvstore.Realm) *PersistentSlotStorage[K, V, KPtr, VPtr]
func (*PersistentSlotStorage[K, V, KPtr, VPtr]) Delete ¶
func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Delete(key K) (success bool)
func (*PersistentSlotStorage[K, V, KPtr, VPtr]) Get ¶
func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Get(key K) (value V, exists bool)
func (*PersistentSlotStorage[K, V, KPtr, VPtr]) Iterate ¶
func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Iterate(index slot.Index, callback func(key K, value V) (advance bool), direction ...kvstore.IterDirection) (err error)
func (*PersistentSlotStorage[K, V, KPtr, VPtr]) Set ¶
func (p *PersistentSlotStorage[K, V, KPtr, VPtr]) Set(key K, value V) (err error)