ax(mining): replace prose comments with usage examples in miner_factory.go

All public function comments restated the signature (AX-2 violation).
Replace each with a concrete call example showing real values.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 07:40:51 +01:00
parent 9ca9c93b9b
commit 1e814bdc80
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -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)
}