engine

package
v0.0.0-...-6ceb869 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockChainCommandName     = "blockchain"
	CalcRewardCommandName     = "calc-reward"
	CalcFeeCommandName        = "calc-fee"
	BlockChainHelpCommandName = "help"
)
View Source
const (
	BoosterCommandName          = "booster"
	BoosterPaymentCommandName   = "payment"
	BoosterClaimCommandName     = "claim"
	BoosterWhitelistCommandName = "whitelist"
	BoosterStatusCommandName    = "status"
	BoosterHelpCommandName      = "help"
)
View Source
const (
	NetworkCommandName       = "network"
	NodeInfoCommandName      = "node-info"
	NetworkStatusCommandName = "status"
	NetworkHealthCommandName = "health"
	NetworkHelpCommandName   = "help"
)
View Source
const (
	P2PCommandName            = "p2p"
	DepositAddressCommandName = "deposit-address"
	CreateOfferCommandName    = "create-offer"
	P2PHelpCommandName        = "help"
)
View Source
const (
	RoboPacCommandName     = "robopac"
	WalletCommandName      = "wallet"
	RoboPacHelpCommandName = "help"
)
View Source
const (
	TestNetRewardCommandName     = "testnet-reward"
	ClaimCommandName             = "claim"
	ClaimerInfoCommandName       = "claimer-info"
	ClaimStatusCommandName       = "status"
	TestNetRewardHelpCommandName = "help"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppID

type AppID int
const (
	AppIdCLI     AppID = 1
	AppIdDiscord AppID = 2
)

type Args

type Args struct {
	Name     string
	Desc     string
	Optional bool
}

type BotEngine

type BotEngine struct {
	AuthIDs []string
	Cmds    []Command

	sync.RWMutex //! remove this.
	// contains filtered or unexported fields
}

func NewBotEngine

func NewBotEngine(cfg *config.Config) (*BotEngine, error)

func (*BotEngine) Commands

func (be *BotEngine) Commands() []Command

func (*BotEngine) NetworkStatus

func (be *BotEngine) NetworkStatus() (*NetStatus, error)

func (*BotEngine) RegisterAllCommands

func (be *BotEngine) RegisterAllCommands()

func (*BotEngine) RegisterBlockchainCommands

func (be *BotEngine) RegisterBlockchainCommands()

func (*BotEngine) RegisterBoosterCommands

func (be *BotEngine) RegisterBoosterCommands()

func (*BotEngine) RegisterNetworkCommands

func (be *BotEngine) RegisterNetworkCommands()

func (*BotEngine) RegisterP2PMarketCommands

func (be *BotEngine) RegisterP2PMarketCommands()

func (*BotEngine) RegisterRoboPacCommands

func (be *BotEngine) RegisterRoboPacCommands()

func (*BotEngine) RegisterTestNetRewardsCommands

func (be *BotEngine) RegisterTestNetRewardsCommands()

func (*BotEngine) Run

func (be *BotEngine) Run(appID AppID, callerID string, inputs []string) (*CommandResult, error)

func (*BotEngine) Start

func (be *BotEngine) Start()

func (*BotEngine) Stop

func (be *BotEngine) Stop()

type Command

type Command struct {
	Name        string
	Desc        string
	Help        string
	Args        []Args //! should be nil for commands.
	AppIDs      []AppID
	SubCommands []*Command
	Handler     func(source AppID, callerID string, args ...string) (*CommandResult, error)
}

func (*Command) CheckArgs

func (cmd *Command) CheckArgs(input []string) error

func (*Command) HasAppId

func (cmd *Command) HasAppId(appID AppID) bool

type CommandResult

type CommandResult struct {
	Message    string
	Successful bool
}

func MakeFailedResult

func MakeFailedResult(message string, a ...interface{}) *CommandResult

func MakeSuccessfulResult

func MakeSuccessfulResult(message string, a ...interface{}) *CommandResult

type IEngine

type IEngine interface {
	Run(appID AppID, callerID string, inputs []string) (*CommandResult, error)
	Commands() []Command

	Stop()
	Start()
}

type NetHealthResponse

type NetHealthResponse struct {
	HealthStatus    bool
	CurrentTime     time.Time
	LastBlockTime   time.Time
	LastBlockHeight uint32
	TimeDifference  int64
}

type NetStatus

type NetStatus struct {
	NetworkName         string
	ConnectedPeersCount uint32
	ValidatorsCount     int32
	TotalBytesSent      uint32
	TotalBytesReceived  uint32
	CurrentBlockHeight  uint32
	TotalNetworkPower   int64
	TotalCommitteePower int64
	TotalAccounts       int32
	CirculatingSupply   int64
}

type NodeInfo

type NodeInfo struct {
	PeerID              string
	IPAddress           string
	Agent               string
	Moniker             string
	Country             string
	City                string
	RegionName          string
	TimeZone            string
	ISP                 string
	ValidatorNum        int32
	AvailabilityScore   float64
	StakeAmount         int64
	LastBondingHeight   uint32
	LastSortitionHeight uint32
}

Jump to

Keyboard shortcuts

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