Documentation ¶
Index ¶
- Constants
- Variables
- type Registry
- func (r *Registry) Cap() uint64
- func (r *Registry) Close() error
- func (r *Registry) Get(pubKey types.SiaPublicKey, tweak crypto.Hash) (modules.SignedRegistryValue, bool)
- func (r *Registry) Len() uint64
- func (r *Registry) Migrate(path string) error
- func (r *Registry) Prune(expiry types.BlockHeight) (uint64, error)
- func (r *Registry) Truncate(newMaxEntries uint64, force bool) error
- func (r *Registry) Update(rv modules.SignedRegistryValue, pubKey types.SiaPublicKey, ...) (srv modules.SignedRegistryValue, _ error)
Constants ¶
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 ¶
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") )
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 (*Registry) Get ¶
func (r *Registry) Get(pubKey types.SiaPublicKey, tweak crypto.Hash) (modules.SignedRegistryValue, bool)
Get fetches the data associated with a key and tweak from the registry.
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 ¶
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 ¶
func (r *Registry) Update(rv modules.SignedRegistryValue, pubKey types.SiaPublicKey, expiry types.BlockHeight) (srv modules.SignedRegistryValue, _ error)
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.