Documentation ¶
Overview ¶
Package rolemgmt allows to work with the native RoleManagement contract via RPC.
Safe methods are encapsulated into ContractReader structure while Contract provides various methods to perform the only RoleManagement state-changing call.
Index ¶
- Variables
- type Actor
- type Contract
- func (c *Contract) DesignateAsRole(role noderoles.Role, pubs keys.PublicKeys) (util.Uint256, uint32, error)
- func (c *Contract) DesignateAsRoleTransaction(role noderoles.Role, pubs keys.PublicKeys) (*transaction.Transaction, error)
- func (c *Contract) DesignateAsRoleUnsigned(role noderoles.Role, pubs keys.PublicKeys) (*transaction.Transaction, error)
- type ContractReader
- type DesignationEvent
- type Invoker
Constants ¶
This section is empty.
Variables ¶
var Hash = state.CreateNativeContractHash(nativenames.Designation)
Hash stores the hash of the native RoleManagement contract.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor interface { Invoker MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error) MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error) SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error) }
Actor is used by Contract to create and send transactions.
type Contract ¶
type Contract struct { ContractReader // contains filtered or unexported fields }
Contract represents a RoleManagement contract client that can be used to invoke all of its methods.
func New ¶
New creates an instance of Contract to perform actions using the given Actor. Notice that RoleManagement's state can be changed only by the network's committee, so the Actor provided must be a committee actor for designation methods to work properly.
func (*Contract) DesignateAsRole ¶
func (c *Contract) DesignateAsRole(role noderoles.Role, pubs keys.PublicKeys) (util.Uint256, uint32, error)
DesignateAsRole creates and sends a transaction that sets the keys used for the given node role. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) DesignateAsRoleTransaction ¶
func (c *Contract) DesignateAsRoleTransaction(role noderoles.Role, pubs keys.PublicKeys) (*transaction.Transaction, error)
DesignateAsRoleTransaction creates a transaction that sets the keys for the given node role. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) DesignateAsRoleUnsigned ¶
func (c *Contract) DesignateAsRoleUnsigned(role noderoles.Role, pubs keys.PublicKeys) (*transaction.Transaction, error)
DesignateAsRoleUnsigned creates a transaction that sets the keys for the given node role. This transaction is not signed and just returned to the caller.
type ContractReader ¶
type ContractReader struct {
// contains filtered or unexported fields
}
ContractReader provides an interface to call read-only RoleManagement contract's methods.
func NewReader ¶
func NewReader(invoker Invoker) *ContractReader
NewReader creates an instance of ContractReader that can be used to read data from the contract.
func (*ContractReader) GetDesignatedByRole ¶
func (c *ContractReader) GetDesignatedByRole(role noderoles.Role, index uint32) (keys.PublicKeys, error)
GetDesignatedByRole returns the list of the keys designated to serve for the given role at the given height. The list can be empty if no keys are configured for this role/height.
type DesignationEvent ¶
DesignationEvent represents an event emitted by RoleManagement contract when a new role designation is done.