|
| 1 | +# pocx_aggregator |
| 2 | + |
| 3 | +High-performance mining aggregator for the PoCX protocol. Acts as a proxy between multiple miners and a single upstream pool or wallet, aggregating submissions and distributing mining information efficiently. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **High Concurrency**: Async/await architecture using Tokio for handling thousands of simultaneous miner connections |
| 8 | +- **Protocol Compliant**: Full JSON-RPC 2.0 support via pocx_protocol |
| 9 | +- **Submission Filtering**: Intelligent per-account or global best submission filtering |
| 10 | +- **Statistics**: Real-time mining statistics and submission tracking |
| 11 | +- **Web Dashboard**: Optional HTTP dashboard for monitoring aggregator status |
| 12 | +- **Database**: SQLite-based submission tracking with configurable retention |
| 13 | + |
| 14 | +## Architecture |
| 15 | + |
| 16 | +The aggregator sits between miners and a single upstream pool/wallet: |
| 17 | + |
| 18 | +``` |
| 19 | +[Miners] <--JSON-RPC--> [Aggregator] <--JSON-RPC--> [Upstream Pool/Wallet] |
| 20 | + | | |
| 21 | + +-- miner1 / \ |
| 22 | + +-- miner2 / \ |
| 23 | + +-- miner3 / \ |
| 24 | + +-- ... / \ |
| 25 | +``` |
| 26 | + |
| 27 | +### Key Components |
| 28 | + |
| 29 | +- **Miner Server**: Accepts connections from miners, serves mining info, accepts nonce submissions |
| 30 | +- **Upstream Client**: Connects to single upstream pool/wallet, fetches mining info, forwards filtered submissions |
| 31 | +- **Submission Queue**: Filters and queues submissions based on mode (Pool/Wallet) |
| 32 | +- **Cache**: Caches mining info to reduce upstream load |
| 33 | +- **Stats**: Tracks submissions, deadlines, and performance metrics |
| 34 | +- **Database**: Stores submission history for statistics and analysis |
| 35 | + |
| 36 | +## Submission Modes |
| 37 | + |
| 38 | +### Pool Mode (Default) |
| 39 | +- Tracks best submission **per account** for last 3 blocks |
| 40 | +- Forwards submissions with retry and exponential backoff |
| 41 | +- Ideal for aggregating submissions to mining pools |
| 42 | + |
| 43 | +### Wallet Mode |
| 44 | +- Tracks **global best** submission across all accounts for last 3 blocks |
| 45 | +- No retry logic (fail fast) |
| 46 | +- Ideal for solo mining to local wallet |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +Create an `aggregator_config.yaml` file: |
| 51 | + |
| 52 | +```yaml |
| 53 | +# Listen address for miner connections |
| 54 | +listen_address: "0.0.0.0:8080" |
| 55 | + |
| 56 | +# Expected block time in seconds |
| 57 | +block_time_secs: 120 |
| 58 | + |
| 59 | +# Upstream pool or wallet |
| 60 | +upstream: |
| 61 | + name: "primary-pool" |
| 62 | + url: "http://pool.example.com:8080/pocx" |
| 63 | + # Optional authentication token |
| 64 | + # auth_token: "your_token_here" |
| 65 | + # Submission mode: pool (default) or wallet |
| 66 | + submission_mode: pool |
| 67 | + |
| 68 | +# Cache settings |
| 69 | +cache: |
| 70 | + mining_info_ttl_secs: 5 |
| 71 | + pool_timeout_secs: 30 |
| 72 | + |
| 73 | +# Database settings |
| 74 | +database: |
| 75 | + path: "aggregator.db" |
| 76 | + retention_days: 7 # 0 = keep forever |
| 77 | + |
| 78 | +# Statistics dashboard (optional) |
| 79 | +dashboard: |
| 80 | + enabled: true |
| 81 | + listen_address: "0.0.0.0:8081" |
| 82 | + |
| 83 | +# Logging |
| 84 | +logging: |
| 85 | + level: "info" |
| 86 | + file: "aggregator.log" |
| 87 | +``` |
| 88 | +
|
| 89 | +## Build |
| 90 | +
|
| 91 | +```bash |
| 92 | +# Build from workspace root |
| 93 | +cargo build --release -p pocx_aggregator |
| 94 | + |
| 95 | +# Or build in this directory |
| 96 | +cargo build --release |
| 97 | +``` |
| 98 | + |
| 99 | +## Run |
| 100 | + |
| 101 | +```bash |
| 102 | +# From workspace root |
| 103 | +./target/release/pocx_aggregator -c aggregator_config.yaml |
| 104 | + |
| 105 | +# Or with custom config path |
| 106 | +./target/release/pocx_aggregator --config /path/to/aggregator_config.yaml |
| 107 | +``` |
| 108 | + |
| 109 | +## Usage |
| 110 | + |
| 111 | +Once running, point your miners to the aggregator: |
| 112 | + |
| 113 | +```yaml |
| 114 | +# miner_config.yaml |
| 115 | +chains: |
| 116 | + - name: "aggregator" |
| 117 | + base_url: "http://localhost:8080" |
| 118 | + api_path: "/" |
| 119 | + accounts: |
| 120 | + - account: "your_account_id" |
| 121 | +``` |
| 122 | +
|
| 123 | +## Development |
| 124 | +
|
| 125 | +```bash |
| 126 | +# Run tests |
| 127 | +cargo test -p pocx_aggregator |
| 128 | + |
| 129 | +# Run with debug logging |
| 130 | +RUST_LOG=debug cargo run -p pocx_aggregator -- -c aggregator_config.yaml |
| 131 | +``` |
| 132 | + |
| 133 | +## License |
| 134 | + |
| 135 | +MIT License - See [LICENSE](../LICENSE) for details. |
0 commit comments