names

package
v0.34.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// 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
)

Variables

View Source
var (
	ErrInvalidLengthNames        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowNames          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupNames = fmt.Errorf("proto: unexpected end of group")
)
View Source
var MinNameRegistrationPeriod uint64 = 5

Functions

func NameBaseCost

func NameBaseCost(name, data string) uint64

base cost is "effective" number of bytes

func NameCostForExpiryIn added in v0.20.0

func NameCostForExpiryIn(name, data string, expiresIn uint64) uint64

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) GetName added in v0.20.0

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

func (*Cache) RemoveName added in v0.20.0

func (cache *Cache) RemoveName(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 Flush if your wish to use the output state as your next backend

func (*Cache) UpdateName added in v0.20.0

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

type Entry

type Entry struct {
	// registered name for the entry
	Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
	// address that created the entry
	Owner github_com_hyperledger_burrow_crypto.Address `protobuf:"bytes,2,opt,name=Owner,proto3,customtype=github.com/hyperledger/burrow/crypto.Address" json:"Owner"`
	// data to store under this name
	Data string `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
	// block at which this entry expires
	Expires              uint64   `protobuf:"varint,4,opt,name=Expires,proto3" json:"Expires,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*Entry) Descriptor added in v0.20.0

func (*Entry) Descriptor() ([]byte, []int)

func (*Entry) Get added in v0.34.4

func (e *Entry) Get(key string) (value interface{}, ok bool)

func (*Entry) GetData added in v0.20.0

func (m *Entry) GetData() string

func (*Entry) GetExpires added in v0.20.0

func (m *Entry) GetExpires() uint64

func (*Entry) GetName added in v0.20.0

func (m *Entry) GetName() string

func (*Entry) Marshal added in v0.20.0

func (m *Entry) Marshal() (dAtA []byte, err error)

func (*Entry) MarshalTo added in v0.20.0

func (m *Entry) MarshalTo(dAtA []byte) (int, error)

func (*Entry) MarshalToSizedBuffer added in v0.34.4

func (m *Entry) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Entry) ProtoMessage added in v0.20.0

func (*Entry) ProtoMessage()

func (*Entry) Reset added in v0.20.0

func (m *Entry) Reset()

func (*Entry) Size added in v0.20.0

func (m *Entry) Size() (n int)

func (*Entry) String added in v0.20.0

func (e *Entry) String() string

func (*Entry) Unmarshal added in v0.20.0

func (m *Entry) Unmarshal(dAtA []byte) error

func (*Entry) XXX_DiscardUnknown added in v0.23.0

func (m *Entry) XXX_DiscardUnknown()

func (*Entry) XXX_Marshal added in v0.23.0

func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Entry) XXX_Merge added in v0.23.0

func (m *Entry) XXX_Merge(src proto.Message)

func (*Entry) XXX_MessageName added in v0.20.0

func (*Entry) XXX_MessageName() string

func (*Entry) XXX_Size added in v0.23.0

func (m *Entry) XXX_Size() int

func (*Entry) XXX_Unmarshal added in v0.23.0

func (m *Entry) XXX_Unmarshal(b []byte) error

type Iterable

type Iterable interface {
	IterateNames(consumer func(*Entry) error) (err error)
}

type IterableReader

type IterableReader interface {
	Iterable
	Reader
}

type IterableReaderWriter

type IterableReaderWriter interface {
	Iterable
	ReaderWriter
}

type Reader

type Reader interface {
	GetName(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
	UpdateName(entry *Entry) error
	// Remove the name entry
	RemoveName(name string) error
}

Jump to

Keyboard shortcuts

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