diff options
| author | Your Name <you@example.com> | 2026-05-19 04:07:16 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 04:07:16 +0530 |
| commit | c75230e551a778408b2e370b208aff76b74c6560 (patch) | |
| tree | 0cf51ecae1c469b7e10272d44b37f69ff4cb611f /main/stratum_proxy.h | |
| parent | abee221b0f0e5a4513ab126afbdfddc2728df6be (diff) | |
feat(mining): add new mining source files and unit tests
- mining_payment.c/h: hashprice calc, share validation, per-client hashrate
- stratum_client.c/h: SV1 upstream pool connection
- stratum_proxy.c/h: local SV1 TCP server for downstream miners
- sw_miner.c/h: software SHA256d miner using mbedtls
- asic_miner.c/h: ASIC detection stub (software fallback)
- test_mining_payment.c: 23 unit tests for mining payment module
Diffstat (limited to 'main/stratum_proxy.h')
| -rw-r--r-- | main/stratum_proxy.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/main/stratum_proxy.h b/main/stratum_proxy.h new file mode 100644 index 0000000..b940640 --- /dev/null +++ b/main/stratum_proxy.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #ifndef STRATUM_PROXY_H | ||
| 2 | #define STRATUM_PROXY_H | ||
| 3 | |||
| 4 | #include "esp_err.h" | ||
| 5 | #include <stdint.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | |||
| 8 | #define STRATUM_MAX_JOB_ID_LEN 32 | ||
| 9 | #define STRATUM_MAX_JOBS 4 | ||
| 10 | |||
| 11 | typedef struct { | ||
| 12 | uint32_t job_id; | ||
| 13 | uint8_t prevhash[32]; | ||
| 14 | uint8_t merkle_root[32]; | ||
| 15 | uint32_t ntime; | ||
| 16 | uint32_t nbits; | ||
| 17 | uint32_t version; | ||
| 18 | uint8_t target[32]; | ||
| 19 | int target_len; | ||
| 20 | bool valid; | ||
| 21 | } stratum_job_t; | ||
| 22 | |||
| 23 | typedef struct { | ||
| 24 | double hashrate_ghs; | ||
| 25 | uint32_t nbits; | ||
| 26 | uint64_t total_shares; | ||
| 27 | uint64_t total_accepted; | ||
| 28 | uint64_t total_rejected; | ||
| 29 | double current_hashprice; | ||
| 30 | int active_miners; | ||
| 31 | } stratum_proxy_stats_t; | ||
| 32 | |||
| 33 | esp_err_t stratum_proxy_init(uint16_t port); | ||
| 34 | void stratum_proxy_set_job(const stratum_job_t *job); | ||
| 35 | const stratum_job_t *stratum_proxy_get_current_job(void); | ||
| 36 | void stratum_proxy_get_stats(stratum_proxy_stats_t *stats); | ||
| 37 | void stratum_proxy_stop(void); | ||
| 38 | |||
| 39 | #endif | ||