node_mgr

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	NODEPREFIX              = "node"
	NODETYPE_PREFIX         = "type"
	VP_NODE_ID_PREFIX       = "vp-id"
	VP_NODE_PID_PREFIX      = "vp-pid"
	NVP_NODE_NAME_PREFIX    = "nvp-name"
	NODE_OCCUPY_PID_PREFIX  = "occupy-node-pid"
	NODE_OCCUPY_NAME_PREFIX = "occupy-node-name"

	VPNode  NodeType = "vpNode"
	NVPNode NodeType = "nvpNode"
)

Variables

This section is empty.

Functions

func NodeKey

func NodeKey(account string) string

func NodeOccupyNameKey

func NodeOccupyNameKey(name string) string

func NodeOccupyPidKey

func NodeOccupyPidKey(pid string) string

func NodeTypeKey

func NodeTypeKey(typ string) string

func NvpNodeNameKey

func NvpNodeNameKey(name string) string

func VpNodeIdKey

func VpNodeIdKey(id string) string

func VpNodePidKey

func VpNodePidKey(pid string) string

Types

type Node

type Node struct {
	Account  string   `toml:"account" json:"account"`
	NodeType NodeType `toml:"node_type" json:"node_type"`

	// VP Node Info
	Pid      string `toml:"pid" json:"pid"`
	VPNodeId uint64 `toml:"id" json:"id"`
	Primary  bool   `toml:"primary" json:"primary"`

	// NVP Node
	Name           string              `toml:"name" json:"name"`
	Permissions    map[string]struct{} `toml:"permissions" json:"permissions"`
	AuditAdminAddr string              `toml:"audit_admin_addr" json:"audit_admin_addr"`

	Status governance.GovernanceStatus `toml:"status" json:"status"`
	FSM    *fsm.FSM                    `json:"fsm"`
}

func (*Node) IsAvailable

func (n *Node) IsAvailable() bool

type NodeManager

type NodeManager struct {
	governance.Persister
}

func (*NodeManager) All

func (nm *NodeManager) All(_ []byte) (interface{}, error)

All returns all nodes

func (*NodeManager) Bind

func (nm *NodeManager) Bind(nodeAccount, auditAdminAddr string) (bool, []byte)

func (*NodeManager) ChangeStatus

func (nm *NodeManager) ChangeStatus(nodeAccount string, trigger, lastStatus string, _ []byte) (bool, []byte)

func (*NodeManager) CountAll

func (nm *NodeManager) CountAll(nodeType []byte) (bool, []byte)

func (*NodeManager) CountAvailable

func (nm *NodeManager) CountAvailable(nodeType []byte) (bool, []byte)

CountAvailable counts all available nodes (available、logouting)

func (*NodeManager) GetAccountByName

func (nm *NodeManager) GetAccountByName(name string) (string, error)

func (*NodeManager) GetAccountByPid

func (nm *NodeManager) GetAccountByPid(pid string) (string, error)

func (*NodeManager) GetAccountByVpId

func (nm *NodeManager) GetAccountByVpId(vpNodeId string) (string, error)

func (*NodeManager) GetAccountMapByType

func (nm *NodeManager) GetAccountMapByType(typ string) *orderedmap.OrderedMap

func (*NodeManager) GovernancePre

func (nm *NodeManager) GovernancePre(nodeAccount string, event governance.EventType, _ []byte) (interface{}, *boltvm.BxhError)

GovernancePre checks if the appchain can do the event. (only check, not modify infomation) return *node, extra info, error

func (*NodeManager) QueryById

func (nm *NodeManager) QueryById(nodeAccount string, _ []byte) (interface{}, error)

func (*NodeManager) Register

func (nm *NodeManager) Register(node *Node)

Register record node info

func (*NodeManager) RegisterPre

func (nm *NodeManager) RegisterPre(node *Node)

func (*NodeManager) Update

func (nm *NodeManager) Update(nodeInfo *Node) (bool, []byte)

type NodeMgr

type NodeMgr interface {
	governance.Governance

	// Register registers node info, return node id and error
	RegisterPre(node *Node)

	Register(node *Node)

	Update(nodeInfo *Node) (bool, []byte)

	Bind(nodeAccount, auditAdminAddr string) (bool, []byte)

	GetAccountMapByType(typ string) *orderedmap.OrderedMap

	GetAccountByVpId(vpNodeId string) (string, error)

	GetAccountByPid(pid string) (string, error)

	GetAccountByName(name string) (string, error)
}

func New

func New(persister governance.Persister) NodeMgr

type NodeType

type NodeType string

Jump to

Keyboard shortcuts

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