2021-03-19 09:11:48 +00:00
|
|
|
/*
|
2022-04-20 18:30:09 +00:00
|
|
|
Package roles provides an interface to RoleManagement native contract.
|
2021-03-19 09:11:48 +00:00
|
|
|
Role management contract is used by committee to designate some nodes as
|
|
|
|
providing some service on the network.
|
|
|
|
*/
|
2021-02-08 08:08:48 +00:00
|
|
|
package roles
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
2021-12-08 19:33:03 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/neogointernal"
|
2021-02-08 08:08:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Hash represents RoleManagement contract hash.
|
2021-02-15 13:40:44 +00:00
|
|
|
const Hash = "\xe2\x95\xe3\x91\x54\x4c\x17\x8a\xd9\x4f\x03\xec\x4d\xcd\xff\x78\x53\x4e\xcf\x49"
|
2021-02-08 08:08:48 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// Role represents a node role.
|
2021-02-08 08:08:48 +00:00
|
|
|
type Role byte
|
|
|
|
|
|
|
|
// Various node roles.
|
|
|
|
const (
|
|
|
|
StateValidator Role = 4
|
|
|
|
Oracle Role = 8
|
2021-03-19 09:12:52 +00:00
|
|
|
NeoFSAlphabet Role = 16
|
2021-03-19 09:11:48 +00:00
|
|
|
// P2PNotary is an extension of Neo protocol available on specifically configured NeoGo networks.
|
|
|
|
P2PNotary Role = 128
|
2021-02-08 08:08:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetDesignatedByRole represents `getDesignatedByRole` method of RoleManagement native contract.
|
|
|
|
func GetDesignatedByRole(r Role, height uint32) []interop.PublicKey {
|
2021-12-08 19:33:03 +00:00
|
|
|
return neogointernal.CallWithToken(Hash, "getDesignatedByRole",
|
|
|
|
int(contract.ReadStates), r, height).([]interop.PublicKey)
|
2021-02-08 08:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DesignateAsRole represents `designateAsRole` method of RoleManagement native contract.
|
|
|
|
func DesignateAsRole(r Role, pubs []interop.PublicKey) {
|
2021-12-08 19:33:03 +00:00
|
|
|
neogointernal.CallWithTokenNoRet(Hash, "designateAsRole",
|
|
|
|
int(contract.States|contract.AllowNotify), r, pubs)
|
2021-02-08 08:08:48 +00:00
|
|
|
}
|