registry

package
v1.5.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PersistedEntrySize is the size of a marshaled entry on disk.
	PersistedEntrySize = modules.RegistryEntrySize
)

TODO: F/Us - use LRU for limited entries in memory, rest on disk - optimize locking by locking each entry individually

Variables

View Source
var (

	// ErrLowerRevNum is returned when the revision number of the data to
	// register isn't greater than the known revision number.
	ErrLowerRevNum = errors.New("provided revision number is invalid")
	// ErrSameRevNum is returned if the revision number of the data to register
	// is already registered.
	ErrSameRevNum = errors.New("provided revision number is already registered")

	// ErrInvalidTruncate is returned if a truncate would lead to data loss.
	ErrInvalidTruncate = errors.New("can't truncate registry below the number of used entries")
)
View Source
var ErrNoFreeBit = errors.New("no free bit available in bitfield")

ErrNoFreeBit is returned by SetRandom if no free bit was found.

Functions

This section is empty.

Types

type Registry

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

Registry is an in-memory key-value store. Renter's can pay the host to register data with a given pubkey and secondary key (tweak).

func New

func New(path string, maxEntries uint64) (_ *Registry, err error)

New creates a new registry or opens an existing one.

func (*Registry) Cap

func (r *Registry) Cap() uint64

Cap returns the capacity of the registry.

func (*Registry) Close

func (r *Registry) Close() error

Close closes the registry and its underlying resources.

func (*Registry) Get

Get fetches the data associated with a key and tweak from the registry.

func (*Registry) Len

func (r *Registry) Len() uint64

Len returns the length of the registry.

func (*Registry) Migrate

func (r *Registry) Migrate(path string) error

Migrate migrates the registry to a new location.

func (*Registry) Prune

func (r *Registry) Prune(expiry types.BlockHeight) (uint64, error)

Prune deletes all entries from the registry that expire at a height smaller than or equal to the provided expiry argument.

func (*Registry) Truncate

func (r *Registry) Truncate(newMaxEntries uint64, force bool) error

Truncate resizes the registry. If 'force' was specified, it will allow to shrink the registry below its current size. This will cause random values to be lost.

func (*Registry) Update

Update adds an entry to the registry or if it exists already, updates it. This will also verify the revision number of the new value and the signature. If an existing entry was updated it will return that entry, otherwise it returns the default value for a SignedRevisionValue.

Jump to

Keyboard shortcuts

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