Mining/docs/DEVELOPMENT.md
snider 757526e60e feat: Add WebSocket events, simulation mode, and redesigned Miners page
WebSocket Real-Time Events:
- Add EventHub for broadcasting miner events to connected clients
- New event types: miner.starting/started/stopping/stopped/stats/error
- WebSocket endpoint at /ws/events with auto-reconnect support
- Angular WebSocketService with RxJS event streams and fallback to polling

Simulation Mode (miner-ctrl simulate):
- SimulatedMiner generates realistic hashrate data for UI development
- Supports presets: cpu-low, cpu-medium, cpu-high, gpu-ethash, gpu-kawpow
- Features: variance, sine-wave fluctuation, 30s ramp-up, 98% share rate
- XMRig-compatible stats format for full UI compatibility
- NewManagerForSimulation() skips autostart of real miners

Miners Page Redesign:
- Featured cards for installed/recommended miners with gradient styling
- "Installed" (green) and "Recommended" (gold) ribbon badges
- Placeholder cards for 8 planned miners with "Coming Soon" badges
- Algorithm badges, GitHub links, and license info for each miner
- Planned miners: T-Rex, lolMiner, Rigel, BzMiner, SRBMiner, TeamRedMiner, GMiner, NBMiner

Chart Improvements:
- Hybrid data approach: live in-memory data while active, database historical when inactive
- Smoother transitions between data sources

Documentation:
- Updated DEVELOPMENT.md with simulation mode usage
- Updated ARCHITECTURE.md with WebSocket, simulation, and supported miners table

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 07:11:41 +00:00

2.1 KiB

Mining Development Guide

This guide is for developers contributing to the Mining project.

Prerequisites

  • Go: Version 1.24 or higher.
  • Make: For running build scripts.
  • Node.js/npm: For building the frontend (optional).

Common Tasks

The project uses a Makefile to automate common tasks.

Simulation Mode

For UI development without real mining hardware, use the simulation mode:

# Start with 3 simulated CPU miners
miner-ctrl simulate --count 3 --preset cpu-high

# Custom hashrate and algorithm
miner-ctrl simulate --count 2 --hashrate 8000 --algorithm rx/0

# Available presets: cpu-low, cpu-medium, cpu-high, gpu-ethash, gpu-kawpow

This generates realistic hashrate data with variance, share events, and pool connections for testing the UI.

Building

Build the CLI binary for the current platform:

make build

Build for all supported platforms (cross-compile):

make build-all

The binaries will be placed in the dist/ directory.

Testing

Run all Go tests:

make test

Run tests with race detection and coverage:

make test-release

Generate and view HTML coverage report:

make coverage

Linting & Formatting

Format code:

make fmt

Run linters (requires golangci-lint):

make lint

Documentation

Generate Swagger documentation from code annotations:

make docs

(Requires swag tool: make install-swag)

Release

The project uses GoReleaser for releases. To create a local snapshot release:

make package

Project Structure

  • pkg/mining: This is where the core logic resides. If you are adding a new feature, you will likely work here.
  • cmd/mining: If you are adding a new CLI command, look here.
  • ui: Frontend code.

Contribution Workflow

  1. Fork the repository.
  2. Create a feature branch.
  3. Make your changes.
  4. Ensure tests pass (make test).
  5. Submit a Pull Request.

CodeRabbit

This project uses CodeRabbit for automated code reviews. Please address any feedback provided by the bot on your PR.