Documentation ¶
Index ¶
- Constants
- Variables
- func FwdCapabilityKey(module string, cap *Capability) []byte
- func IndexFromKey(key []byte) uint64
- func IndexToKey(index uint64) []byte
- func RegisterCodec(cdc *codec.Codec)
- func RevCapabilityKey(module, name string) []byte
- type Capability
- func (*Capability) Descriptor() ([]byte, []int)
- func (m *Capability) GetIndex() uint64
- func (m *Capability) Marshal() (dAtA []byte, err error)
- func (m *Capability) MarshalTo(dAtA []byte) (int, error)
- func (m *Capability) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Capability) ProtoMessage()
- func (m *Capability) Reset()
- func (m *Capability) Size() (n int)
- func (ck *Capability) String() string
- func (m *Capability) Unmarshal(dAtA []byte) error
- func (m *Capability) XXX_DiscardUnknown()
- func (m *Capability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Capability) XXX_Merge(src proto.Message)
- func (m *Capability) XXX_Size() int
- func (m *Capability) XXX_Unmarshal(b []byte) error
- type CapabilityOwners
- func (*CapabilityOwners) Descriptor() ([]byte, []int)
- func (co *CapabilityOwners) Get(owner Owner) (int, bool)
- func (m *CapabilityOwners) GetOwners() []Owner
- func (m *CapabilityOwners) Marshal() (dAtA []byte, err error)
- func (m *CapabilityOwners) MarshalTo(dAtA []byte) (int, error)
- func (m *CapabilityOwners) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*CapabilityOwners) ProtoMessage()
- func (co *CapabilityOwners) Remove(owner Owner)
- func (m *CapabilityOwners) Reset()
- func (co *CapabilityOwners) Set(owner Owner) error
- func (m *CapabilityOwners) Size() (n int)
- func (m *CapabilityOwners) String() string
- func (m *CapabilityOwners) Unmarshal(dAtA []byte) error
- func (m *CapabilityOwners) XXX_DiscardUnknown()
- func (m *CapabilityOwners) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CapabilityOwners) XXX_Merge(src proto.Message)
- func (m *CapabilityOwners) XXX_Size() int
- func (m *CapabilityOwners) XXX_Unmarshal(b []byte) error
- type GenesisOwners
- type GenesisState
- type Owner
- func (*Owner) Descriptor() ([]byte, []int)
- func (o Owner) Key() string
- func (m *Owner) Marshal() (dAtA []byte, err error)
- func (m *Owner) MarshalTo(dAtA []byte) (int, error)
- func (m *Owner) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Owner) ProtoMessage()
- func (m *Owner) Reset()
- func (m *Owner) Size() (n int)
- func (o Owner) String() string
- func (m *Owner) Unmarshal(dAtA []byte) error
- func (m *Owner) XXX_DiscardUnknown()
- func (m *Owner) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Owner) XXX_Merge(src proto.Message)
- func (m *Owner) XXX_Size() int
- func (m *Owner) XXX_Unmarshal(b []byte) error
Constants ¶
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" )
const DefaultIndex uint64 = 1
DefaultIndex is the default capability global index
Variables ¶
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
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") )
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 ¶
IndexFromKey returns an index from a call to IndexToKey for a given capability index.
func IndexToKey ¶
IndexToKey returns bytes to be used as a key for a given capability index.
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for the capability module.
func RevCapabilityKey ¶
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) 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) 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 (*Owner) Descriptor ¶
func (*Owner) ProtoMessage ¶
func (*Owner) ProtoMessage()
func (*Owner) XXX_DiscardUnknown ¶
func (m *Owner) XXX_DiscardUnknown()