Documentation ¶
Index ¶
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" )
Variables ¶
var ( ErrInvalidCapabilityName = sdkerrors.Register(ModuleName, 2, "capability name not valid") ErrNilCapability = sdkerrors.Register(ModuleName, 3, "provided capability is nil") ErrCapabilityTaken = sdkerrors.Register(ModuleName, 4, "capability name already taken") ErrOwnerClaimed = sdkerrors.Register(ModuleName, 5, "given owner already claimed capability") ErrCapabilityNotOwned = sdkerrors.Register(ModuleName, 6, "capability not owned by module") ErrCapabilityNotFound = sdkerrors.Register(ModuleName, 7, "capability not found") ErrCapabilityOwnersNotFound = sdkerrors.Register(ModuleName, 8, "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 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"`
}
func NewCapability ¶
func NewCapability(index uint64) *Capability
NewCapability returns a reference to a new Capability to be used as an actual capability.
func (*Capability) GetIndex ¶
func (m *Capability) GetIndex() uint64
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.
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) 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) 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) 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.