cache

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

Cache is a generic cache that maintains items that are seen and hard confirmed

func NewCache

func NewCache[T any]() *Cache[T]

NewCache returns a new Cache struct

func (*Cache[T]) DeleteItem

func (c *Cache[T]) DeleteItem(height uint64)

DeleteItem deletes an item from the cache by height

func (*Cache[T]) GetDAIncludedHeight

func (c *Cache[T]) GetDAIncludedHeight(hash string) (uint64, bool)

func (*Cache[T]) GetItem

func (c *Cache[T]) GetItem(height uint64) *T

GetItem returns an item from the cache by height

func (*Cache[T]) IsDAIncluded

func (c *Cache[T]) IsDAIncluded(hash string) bool

IsDAIncluded returns true if the hash has been DA-included

func (*Cache[T]) IsSeen

func (c *Cache[T]) IsSeen(hash string) bool

IsSeen returns true if the hash has been seen

func (*Cache[T]) LoadFromDisk

func (c *Cache[T]) LoadFromDisk(folderPath string) error

LoadFromDisk loads the cache contents from disk from the specified folder. It populates the current cache instance. If files are missing, corresponding parts of the cache will be empty. It's the caller's responsibility to ensure that type T (and any types it contains) are registered with the gob package if necessary (e.g., using gob.Register).

func (*Cache[T]) SaveToDisk

func (c *Cache[T]) SaveToDisk(folderPath string) error

SaveToDisk saves the cache contents to disk in the specified folder. It's the caller's responsibility to ensure that type T (and any types it contains) are registered with the gob package if necessary (e.g., using gob.Register).

func (*Cache[T]) SetDAIncluded

func (c *Cache[T]) SetDAIncluded(hash string, height uint64)

SetDAIncluded sets the hash as DA-included with the given height

func (*Cache[T]) SetItem

func (c *Cache[T]) SetItem(height uint64, item *T)

SetItem sets an item in the cache by height

func (*Cache[T]) SetSeen

func (c *Cache[T]) SetSeen(hash string)

SetSeen sets the hash as seen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL