names

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MinNameRegistrationPeriod uint64 = 5

	// cost for storing a name for a block is
	// CostPerBlock*CostPerByte*(len(data) + 32)
	NameByteCostMultiplier  uint64 = 1
	NameBlockCostMultiplier uint64 = 1

	MaxNameLength = 64
	MaxDataLength = 1 << 16
)

Functions

func NameBaseCost

func NameBaseCost(name, data string) uint64

base cost is "effective" number of bytes

func NameCostPerBlock

func NameCostPerBlock(baseCost uint64) uint64

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

The Cache helps prevent unnecessary IAVLTree updates and garbage generation.

func NewCache

func NewCache(backend Reader) *Cache

Returns a Cache that wraps an underlying NameRegCacheGetter to use on a cache miss, can write to an output Writer via Sync. Not goroutine safe, use syncStateCache if you need concurrent access

func (*Cache) Backend

func (cache *Cache) Backend() Reader

func (*Cache) Flush

func (cache *Cache) Flush(output Writer, backend Reader) error

Syncs the Cache and Resets it to use Writer as the backend Reader

func (*Cache) GetNameEntry

func (cache *Cache) GetNameEntry(name string) (*Entry, error)

func (*Cache) RemoveNameEntry

func (cache *Cache) RemoveNameEntry(name string) error

func (*Cache) Reset

func (cache *Cache) Reset(backend Reader)

Resets the cache to empty initialising the backing map to the same size as the previous iteration.

func (*Cache) Sync

func (cache *Cache) Sync(state Writer) error

Writes whatever is in the cache to the output Writer state. Does not flush the cache, to do that call Reset() after Sync or use Flusth if your wish to use the output state as your next backend

func (*Cache) UpdateNameEntry

func (cache *Cache) UpdateNameEntry(entry *Entry) error

type Entry

type Entry struct {
	// registered name for the entry
	Name string
	// address that created the entry
	Owner crypto.Address
	// data to store under this name
	Data string
	// block at which this entry expires
	Expires uint64
}

NameReg provides a global key value store based on Name, Data pairs that are subject to expiry and ownership by an account.

func DecodeEntry

func DecodeEntry(entryBytes []byte) (*Entry, error)

func (*Entry) Encode

func (e *Entry) Encode() ([]byte, error)

type Iterable

type Iterable interface {
	IterateNameEntries(consumer func(*Entry) (stop bool)) (stopped bool, err error)
}

type IterableReader

type IterableReader interface {
	Iterable
	Reader
}

type IterableReaderWriter

type IterableReaderWriter interface {
	Iterable
	ReaderWriter
}

type Reader

type Reader interface {
	GetNameEntry(name string) (*Entry, error)
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

type Writer

type Writer interface {
	// Updates the name entry creating it if it does not exist
	UpdateNameEntry(entry *Entry) error
	// Remove the name entry
	RemoveNameEntry(name string) error
}

Jump to

Keyboard shortcuts

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