rule_mgr

package
v0.0.0-...-de91b87 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RulePrefix = "rule"
)

Variables

This section is empty.

Functions

func IsDefault

func IsDefault(addr, chainType string) bool

func RuleKey

func RuleKey(chainID string) string

Types

type Rule

type Rule struct {
	Address    string                      `json:"address"`
	RuleUrl    string                      `json:"rule_url"`
	ChainID    string                      `json:"chain_id"`
	Master     bool                        `json:"master"`
	Default    bool                        `json:"builtIn"`
	CreateTime int64                       `json:"create_time"`
	Status     governance.GovernanceStatus `json:"status"`
	FSM        *fsm.FSM                    `json:"fsm"`
}

func (*Rule) GetChainRuleID

func (r *Rule) GetChainRuleID() string

func (*Rule) IsAvailable

func (r *Rule) IsAvailable() bool

type RuleManager

type RuleManager struct {
	governance.Persister
}

func (*RuleManager) All

func (rm *RuleManager) All(chainID []byte) (interface{}, error)

Appchains returns all appchains

func (*RuleManager) AllRules

func (rm *RuleManager) AllRules() ([]*Rule, error)

func (*RuleManager) ChangeStatus

func (rm *RuleManager) ChangeStatus(ruleAddress, trigger, lastStatus string, chainID []byte) (bool, []byte)

func (*RuleManager) CountAll

func (rm *RuleManager) CountAll(chainID []byte) (bool, []byte)

func (*RuleManager) CountAvailable

func (rm *RuleManager) CountAvailable(chainID []byte) (bool, []byte)

CountAvailable counts all rules of one appchain including available

func (*RuleManager) GetMaster

func (rm *RuleManager) GetMaster(chainID string) (*Rule, error)

func (*RuleManager) GovernancePre

func (rm *RuleManager) GovernancePre(ruleAddress string, event governance.EventType, chainID []byte) (interface{}, *boltvm.BxhError)

GovernancePre checks if the rule address can do event with appchain id and record rule. (only check, not modify infomation)

func (*RuleManager) HasMaster

func (rm *RuleManager) HasMaster(chainID string) bool

func (*RuleManager) IsAvailable

func (rm *RuleManager) IsAvailable(chainID, ruleAddress string) bool

func (*RuleManager) QueryById

func (rm *RuleManager) QueryById(ruleAddress string, chainID []byte) (interface{}, error)

func (*RuleManager) Register

func (rm *RuleManager) Register(chainID, ruleAddress, ruleUrl string, createTime int64, isDefault bool)

Register record rule

type RuleMgr

type RuleMgr interface {
	governance.Governance

	Register(chainID, ruleAddress, ruleUrl string, createTime int64, isDefault bool)

	GetMaster(chainId string) (*Rule, error)

	HasMaster(chainId string) bool

	IsAvailable(chainId, ruleId string) bool

	AllRules() ([]*Rule, error)
}

func New

func New(persister governance.Persister) RuleMgr

Jump to

Keyboard shortcuts

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