types

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ModuleName defines the module name
	ModuleName = "capability"

	// StoreKey defines the primary module store key
	StoreKey = ModuleName

	// MemStoreKey defines the in-memory store key
	MemStoreKey = "mem_capability"
)
View Source
const DefaultIndex uint64 = 1

DefaultIndex is the default capability global index

Variables

View Source
var (
	ErrCapabilityTaken          = sdkerrors.Register(ModuleName, 2, "capability name already taken")
	ErrOwnerClaimed             = sdkerrors.Register(ModuleName, 3, "given owner already claimed capability")
	ErrCapabilityNotOwned       = sdkerrors.Register(ModuleName, 4, "capability not owned by module")
	ErrCapabilityNotFound       = sdkerrors.Register(ModuleName, 5, "capability not found")
	ErrCapabilityOwnersNotFound = sdkerrors.Register(ModuleName, 6, "owners not found for capability")
)

x/capability module sentinel errors

View Source
var (
	// KeyIndex defines the key that stores the current globally unique capability
	// index.
	KeyIndex = []byte("index")

	// KeyPrefixIndexCapability defines a key prefix that stores index to capability
	// name mappings.
	KeyPrefixIndexCapability = []byte("capability_index")
)
View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)

Functions

func FwdCapabilityKey

func FwdCapabilityKey(module string, cap *Capability) []byte

FwdCapabilityKey returns a forward lookup key for a given module and capability reference.

func IndexFromKey

func IndexFromKey(key []byte) uint64

IndexFromKey returns an index from a call to IndexToKey for a given capability index.

func IndexToKey

func IndexToKey(index uint64) []byte

IndexToKey returns bytes to be used as a key for a given capability index.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers all the necessary types and interfaces for the capability module.

func RevCapabilityKey

func RevCapabilityKey(module, name string) []byte

RevCapabilityKey returns a reverse lookup key for a given module and capability name.

Types

type Capability

type Capability struct {
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty" yaml:"index"`
}

Capability defines an implementation of an object capability. The index provided to a Capability must be globally unique.

func NewCapability

func NewCapability(index uint64) *Capability

NewCapability returns a reference to a new Capability to be used as an actual capability.

func (*Capability) Descriptor

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

func (*Capability) GetIndex

func (m *Capability) GetIndex() uint64

func (*Capability) Marshal

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

func (*Capability) MarshalTo

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

func (*Capability) MarshalToSizedBuffer

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

func (*Capability) ProtoMessage

func (*Capability) ProtoMessage()

func (*Capability) Reset

func (m *Capability) Reset()

func (*Capability) Size

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

func (*Capability) String

func (ck *Capability) String() string

String returns the string representation of a Capability. The string contains the Capability's memory reference as the string is to be used in a composite key and to authenticate capabilities.

func (*Capability) Unmarshal

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

func (*Capability) XXX_DiscardUnknown

func (m *Capability) XXX_DiscardUnknown()

func (*Capability) XXX_Marshal

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

func (*Capability) XXX_Merge

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

func (*Capability) XXX_Size

func (m *Capability) XXX_Size() int

func (*Capability) XXX_Unmarshal

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

type CapabilityOwners

type CapabilityOwners struct {
	Owners []Owner `protobuf:"bytes,1,rep,name=owners,proto3" json:"owners"`
}

CapabilityOwners defines a set of owners of a single Capability. The set of owners must be unique.

func NewCapabilityOwners

func NewCapabilityOwners() *CapabilityOwners

func (*CapabilityOwners) Descriptor

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

func (*CapabilityOwners) Get

func (co *CapabilityOwners) Get(owner Owner) (int, bool)

Get returns (i, true) of the provided owner in the CapabilityOwners if the owner exists, where i indicates the owner's index in the set. Otherwise (i, false) where i indicates where in the set the owner should be added.

func (*CapabilityOwners) GetOwners

func (m *CapabilityOwners) GetOwners() []Owner

func (*CapabilityOwners) Marshal

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

func (*CapabilityOwners) MarshalTo

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

func (*CapabilityOwners) MarshalToSizedBuffer

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

func (*CapabilityOwners) ProtoMessage

func (*CapabilityOwners) ProtoMessage()

func (*CapabilityOwners) Remove

func (co *CapabilityOwners) Remove(owner Owner)

Remove removes a provided owner from the CapabilityOwners if it exists. If the owner does not exist, Remove is considered a no-op.

func (*CapabilityOwners) Reset

func (m *CapabilityOwners) Reset()

func (*CapabilityOwners) Set

func (co *CapabilityOwners) Set(owner Owner) error

Set attempts to add a given owner to the CapabilityOwners. If the owner already exists, an error will be returned. Set runs in O(log n) average time and O(n) in the worst case.

func (*CapabilityOwners) Size

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

func (*CapabilityOwners) String

func (m *CapabilityOwners) String() string

func (*CapabilityOwners) Unmarshal

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

func (*CapabilityOwners) XXX_DiscardUnknown

func (m *CapabilityOwners) XXX_DiscardUnknown()

func (*CapabilityOwners) XXX_Marshal

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

func (*CapabilityOwners) XXX_Merge

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

func (*CapabilityOwners) XXX_Size

func (m *CapabilityOwners) XXX_Size() int

func (*CapabilityOwners) XXX_Unmarshal

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

type GenesisOwners

type GenesisOwners struct {
	Index  uint64           `json:"index" yaml:"index"`
	Owners CapabilityOwners `json:"index_owners" yaml:"index_owners"`
}

GenesisOwners defines the capability owners with their corresponding index.

type GenesisState

type GenesisState struct {
	// capability global index
	Index uint64 `json:"index" yaml:"index"`

	// map from index to owners of the capability index
	// index key is string to allow amino marshalling
	Owners []GenesisOwners `json:"owners" yaml:"owners"`
}

GenesisState represents the Capability module genesis state

func DefaultGenesis

func DefaultGenesis() GenesisState

DefaultGenesis returns the default Capability genesis state

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

type Owner

type Owner struct {
	Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty" yaml:"module"`
	Name   string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"`
}

Owner defines a single capability owner. An owner is defined by the name of capability and the module name.

func NewOwner

func NewOwner(module, name string) Owner

func (*Owner) Descriptor

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

func (Owner) Key

func (o Owner) Key() string

Key returns a composite key for an Owner.

func (*Owner) Marshal

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

func (*Owner) MarshalTo

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

func (*Owner) MarshalToSizedBuffer

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

func (*Owner) ProtoMessage

func (*Owner) ProtoMessage()

func (*Owner) Reset

func (m *Owner) Reset()

func (*Owner) Size

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

func (Owner) String

func (o Owner) String() string

func (*Owner) Unmarshal

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

func (*Owner) XXX_DiscardUnknown

func (m *Owner) XXX_DiscardUnknown()

func (*Owner) XXX_Marshal

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

func (*Owner) XXX_Merge

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

func (*Owner) XXX_Size

func (m *Owner) XXX_Size() int

func (*Owner) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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