config

package
v0.0.0-...-593eaa3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBPool *sql.DB

Functions

func AutoMigrate

func AutoMigrate(ctx context.Context, db *sql.DB, cfg *AppConfig) error

AutoMigrate 自动检查并创建所需的表

func GetConfigDir

func GetConfigDir() string

func GetConfigPath

func GetConfigPath() string

func GetContracts

func GetContracts(ctx context.Context, db *sql.DB, chainName string, limit int) ([]internal.Contract, error)

func GetContractsByAddresses

func GetContractsByAddresses(ctx context.Context, db *sql.DB, chainName string, addresses []string) ([]internal.Contract, error)

func GetTableName

func GetTableName(chainName string) (string, error)

func InitDB

func InitDB(ctx context.Context) (*sql.DB, error)

helloq InitDB 初始化 MySQL 连接池

Types

type AIConfig

type AIConfig struct {
	OpenAI   AIProvider `yaml:"openai"`
	DeepSeek AIProvider `yaml:"deepseek"`
	Gemini   AIProvider `yaml:"gemini"`
	LocalLLM AIProvider `yaml:"local_llm"`
}

type AIProvider

type AIProvider struct {
	APIKey  string `yaml:"api_key"`
	BaseURL string `yaml:"base_url"`
	Model   string `yaml:"model"`
	Proxy   string `yaml:"proxy"`
}

type APIKeyManager

type APIKeyManager struct {
	// contains filtered or unexported fields
}

func GetAPIKeyManager

func GetAPIKeyManager(chainName string) (*APIKeyManager, error)

func NewAPIKeyManager

func NewAPIKeyManager(apiKeys []string, fallbackKey string) *APIKeyManager

func (*APIKeyManager) GetKey

func (m *APIKeyManager) GetKey() string

func (*APIKeyManager) GetKeyCount

func (m *APIKeyManager) GetKeyCount() int

func (*APIKeyManager) GetNextKey

func (m *APIKeyManager) GetNextKey() string

func (*APIKeyManager) GetRandomKey

func (m *APIKeyManager) GetRandomKey() string

func (*APIKeyManager) HasKeys

func (m *APIKeyManager) HasKeys() bool

type AppConfig

type AppConfig struct {
	AI       AIConfig               `yaml:"ai"`
	Chains   map[string]ChainConfig `yaml:"chains"`
	Database DatabaseConfig         `yaml:"database"`
}
var GlobalConfig *AppConfig

func LoadConfig

func LoadConfig() (*AppConfig, error)

helloq LoadConfig 加载 YAML 配置

func (*AppConfig) GetAIConfig

func (c *AppConfig) GetAIConfig(provider string) (*AIProvider, error)

func (*AppConfig) GetChainConfig

func (c *AppConfig) GetChainConfig(chainName string) (*ChainConfig, error)

func (*AppConfig) GetDatabaseDSN

func (c *AppConfig) GetDatabaseDSN(includeDBName bool) string

type BlockRange

type BlockRange struct {
	Start uint64
	End   uint64
}

type ChainConfig

type ChainConfig struct {
	Name      string   `yaml:"name"`
	ChainID   int      `yaml:"chain_id"`
	RPCURLs   []string `yaml:"rpc_urls"`
	Explorer  Explorer `yaml:"explorer"`
	TableName string   `yaml:"table_name"`
}

func GetChainConfig

func GetChainConfig(chainName string) (*ChainConfig, error)

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Name     string `yaml:"name"`
}

type Explorer

type Explorer struct {
	APIKey  string   `yaml:"api_key"`
	APIKeys []string `yaml:"api_keys"`
	BaseURL string   `yaml:"base_url"`
}

func GetExplorerConfig

func GetExplorerConfig(chainName string) (*Explorer, error)

type RPCManager

type RPCManager struct {
	// contains filtered or unexported fields
}

func GetRPCManager

func GetRPCManager(chainName string, proxy string) (*RPCManager, error)

func NewRPCManager

func NewRPCManager(chainName string, urls []string, timeout time.Duration, proxy string) (*RPCManager, error)

func (*RPCManager) Close

func (r *RPCManager) Close()

func (*RPCManager) GetChainName

func (r *RPCManager) GetChainName() string

func (*RPCManager) GetClient

func (r *RPCManager) GetClient() (*ethclient.Client, error)

func (*RPCManager) GetCurrentURL

func (r *RPCManager) GetCurrentURL() string

func (*RPCManager) GetStatus

func (r *RPCManager) GetStatus() map[string]interface{}

type ScanConfiguration

type ScanConfiguration struct {
	// AI 相关
	AIProvider string
	APIKey     string // 最终使用的 API Key
	BaseURL    string
	Model      string
	Timeout    time.Duration

	// 扫描相关
	Mode          string
	Strategy      string
	TargetSource  string
	TargetFile    string
	TargetAddress string
	BlockRange    *BlockRange
	Chain         string
	Concurrency   int
	InputFile     string

	// 系统相关
	Proxy     string
	Verbose   bool
	ReportDir string

	// Benchmark related
	Benchmark bool
	Database  string
}

func DefaultScanConfiguration

func DefaultScanConfiguration() ScanConfiguration

Jump to

Keyboard shortcuts

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