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

    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

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

        func (*Cache) RemoveName

        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

            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

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

              func (*Entry) Get

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

              func (*Entry) GetData

              func (m *Entry) GetData() string

              func (*Entry) GetExpires

              func (m *Entry) GetExpires() uint64

              func (*Entry) GetName

              func (m *Entry) GetName() string

              func (*Entry) Marshal

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

              func (*Entry) MarshalTo

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

              func (*Entry) MarshalToSizedBuffer

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

              func (*Entry) ProtoMessage

              func (*Entry) ProtoMessage()

              func (*Entry) Reset

              func (m *Entry) Reset()

              func (*Entry) Size

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

              func (*Entry) String

              func (e *Entry) String() string

              func (*Entry) Unmarshal

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

              func (*Entry) XXX_DiscardUnknown

              func (m *Entry) XXX_DiscardUnknown()

              func (*Entry) XXX_Marshal

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

              func (*Entry) XXX_Merge

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

              func (*Entry) XXX_MessageName

              func (*Entry) XXX_MessageName() string

              func (*Entry) XXX_Size

              func (m *Entry) XXX_Size() int

              func (*Entry) XXX_Unmarshal

              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
              }