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

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 07:48:45 +01:00
parent 873ccaee7b
commit a3d697b45e
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -204,54 +204,59 @@ func (c *Container) Shutdown(ctx context.Context) error {
return nil
}
// Manager returns the miner manager.
// miner := container.Manager()
// miner.StartMiner(ctx, "xmrig", config)
func (c *Container) Manager() ManagerInterface {
c.mu.RLock()
defer c.mu.RUnlock()
return c.manager
}
// ProfileManager returns the profile manager.
// pm := container.ProfileManager()
// pm.SaveProfile("eth-main", config)
func (c *Container) ProfileManager() *ProfileManager {
c.mu.RLock()
defer c.mu.RUnlock()
return c.profileManager
}
// NodeService returns the node service (may be nil if P2P is unavailable).
// ns := container.NodeService() // nil if P2P is unavailable
// ns.GetPeers()
func (c *Container) NodeService() *NodeService {
c.mu.RLock()
defer c.mu.RUnlock()
return c.nodeService
}
// EventHub returns the event hub for WebSocket connections.
// hub := container.EventHub()
// hub.Broadcast(event)
func (c *Container) EventHub() *EventHub {
c.mu.RLock()
defer c.mu.RUnlock()
return c.eventHub
}
// HashrateStore returns the hashrate store interface.
// store := container.HashrateStore()
// store.RecordHashrate("xmrig", 1234.5)
func (c *Container) HashrateStore() database.HashrateStore {
c.mu.RLock()
defer c.mu.RUnlock()
return c.hashrateStore
}
// SetHashrateStore allows injecting a custom hashrate store (useful for testing).
// container.SetHashrateStore(database.NopStore()) // inject no-op store in tests
func (c *Container) SetHashrateStore(store database.HashrateStore) {
c.mu.Lock()
defer c.mu.Unlock()
c.hashrateStore = store
}
// ShutdownCh returns a channel that's closed when shutdown is complete.
// <-container.ShutdownCh() // blocks until shutdown is complete
func (c *Container) ShutdownCh() <-chan struct{} {
return c.shutdownCh
}
// IsInitialized returns true if the container has been initialized.
// if container.IsInitialized() { container.Start(ctx) }
func (c *Container) IsInitialized() bool {
c.mu.RLock()
defer c.mu.RUnlock()