diff --git a/pkg/mining/miner_factory.go b/pkg/mining/miner_factory.go index 2f90cb2..b6dbdff 100644 --- a/pkg/mining/miner_factory.go +++ b/pkg/mining/miner_factory.go @@ -49,21 +49,21 @@ func (f *MinerFactory) registerDefaults() { }) } -// Register adds a miner constructor to the factory +// f.Register("xmrig", func() Miner { return NewXMRigMiner() }) func (f *MinerFactory) Register(name string, constructor MinerConstructor) { f.mu.Lock() defer f.mu.Unlock() f.constructors[strings.ToLower(name)] = constructor } -// RegisterAlias adds an alias for an existing miner type +// f.RegisterAlias("ttminer", "tt-miner") func (f *MinerFactory) RegisterAlias(alias, canonicalName string) { f.mu.Lock() defer f.mu.Unlock() f.aliases[strings.ToLower(alias)] = strings.ToLower(canonicalName) } -// Create instantiates a miner of the specified type +// miner, err := factory.Create("xmrig") func (f *MinerFactory) Create(minerType string) (Miner, error) { f.mu.RLock() defer f.mu.RUnlock() @@ -83,7 +83,7 @@ func (f *MinerFactory) Create(minerType string) (Miner, error) { return constructor(), nil } -// IsSupported checks if a miner type is registered +// if factory.IsSupported("tt-miner") { ... } func (f *MinerFactory) IsSupported(minerType string) bool { f.mu.RLock() defer f.mu.RUnlock() @@ -99,7 +99,7 @@ func (f *MinerFactory) IsSupported(minerType string) bool { return ok } -// ListTypes returns all registered miner type names (excluding aliases) +// types := factory.ListTypes() // ["xmrig", "tt-miner", "simulated"] func (f *MinerFactory) ListTypes() []string { f.mu.RLock() defer f.mu.RUnlock() @@ -113,27 +113,27 @@ func (f *MinerFactory) ListTypes() []string { // --- Global factory functions for convenience --- -// CreateMiner creates a miner using the global factory +// miner, err := CreateMiner("xmrig") func CreateMiner(minerType string) (Miner, error) { return globalFactory.Create(minerType) } -// IsMinerSupported checks if a miner type is supported using the global factory +// if IsMinerSupported("tt-miner") { ... } func IsMinerSupported(minerType string) bool { return globalFactory.IsSupported(minerType) } -// ListMinerTypes returns all registered miner types from the global factory +// types := ListMinerTypes() // ["xmrig", "tt-miner", "simulated"] func ListMinerTypes() []string { return globalFactory.ListTypes() } -// RegisterMinerType adds a miner constructor to the global factory +// RegisterMinerType("custom", func() Miner { return NewCustomMiner() }) func RegisterMinerType(name string, constructor MinerConstructor) { globalFactory.Register(name, constructor) } -// RegisterMinerAlias adds an alias to the global factory +// RegisterMinerAlias("ttminer", "tt-miner") func RegisterMinerAlias(alias, canonicalName string) { globalFactory.RegisterAlias(alias, canonicalName) }