capability

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*Capabilities
}

API abstracts RPC API access to capabilities controls will in the future provide notifications of capability changes

func NewAPI

func NewAPI(c *Capabilities) *API

NetAPI creates new API abstraction around provided Capabilities object

func (*API) IsRegisteredCapability

func (a *API) IsRegisteredCapability(id CapabilityID) (bool, error)

IsRegisteredCapability returns true if a Capability with the given id is registered

func (*API) MatchCapability

func (a *API) MatchCapability(id CapabilityID, idx int) (bool, error)

MatchCapability returns true if the Capability flag at the given index is set Fails with error if the Capability is not registered, or if the index is out of bounds

func (*API) RegisterCapability

func (a *API) RegisterCapability(cp *Capability) error

RegisterCapability adds the given capability object to the Capabilities collection If the Capability is already registered an error will be returned

type Capabilities

type Capabilities struct {
	Caps []*Capability
	// contains filtered or unexported fields
}

Capabilities is the collection of capabilities for a Swarm node It is used both to store the capabilities in the node, and to communicate the node capabilities to its peers

func NewCapabilities

func NewCapabilities() *Capabilities

NewCapabilities initializes a new Capabilities object

func (*Capabilities) Add

func (c *Capabilities) Add(cp *Capability) error

adds a capability to the Capabilities collection

func (*Capabilities) DecodeRLP

func (c *Capabilities) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.RLPDecoder this custom deserializer builds the module id to array index map state of receiver is undefined on error

func (*Capabilities) Get

func (c *Capabilities) Get(id CapabilityID) *Capability

gets the capability with the specified module id returns nil if the id doesn't exist

func (*Capabilities) Match

func (c *Capabilities) Match(capsCompare *Capabilities) bool

Match returns true if all bits set in all capability arguments are also set in the receiver's capabilities

func (*Capabilities) String

func (c *Capabilities) String() (s string)

String Implements Stringer interface

type Capability

type Capability struct {
	Id  CapabilityID
	Cap []bool
}

Capability contains a bit vector of flags that define what capability a node has in a specific module The module is defined by the Id.

func NewCapability

func NewCapability(id CapabilityID, bitCount int) *Capability

NewCapability initializes a new Capability with the given id and specified number of bits in the vector

func (*Capability) IsSameAs

func (c *Capability) IsSameAs(cp *Capability) bool

IsSameAs returns true if the given Capability object has the identical bit settings as the receiver

func (*Capability) Match

func (c *Capability) Match(capCompare *Capability) bool

Match returns true if all bits set in the argument is also set in the receiver

func (*Capability) Set

func (c *Capability) Set(idx int) error

Set switches the bit at the specified index on

func (*Capability) String

func (c *Capability) String() (s string)

String implements Stringer interface

func (*Capability) Unset

func (c *Capability) Unset(idx int) error

Unset switches the bit at the specified index off

type CapabilityID

type CapabilityID uint64

CapabilityID defines a unique type of capability

Jump to

Keyboard shortcuts

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