diff options
Diffstat (limited to 'main/mining_payment.h')
| -rw-r--r-- | main/mining_payment.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/main/mining_payment.h b/main/mining_payment.h new file mode 100644 index 0000000..c5ce0f2 --- /dev/null +++ b/main/mining_payment.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #ifndef MINING_PAYMENT_H | ||
| 2 | #define MINING_PAYMENT_H | ||
| 3 | |||
| 4 | #include "esp_err.h" | ||
| 5 | #include <stdint.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | |||
| 8 | #define MINING_SHARE_WINDOW_S 30 | ||
| 9 | #define MINING_BLOCK_SUBSIDY_SATS 312500000ULL | ||
| 10 | #define MINING_BLOCKS_PER_DAY 144ULL | ||
| 11 | #define MINING_MAX_CLIENTS 10 | ||
| 12 | |||
| 13 | typedef struct { | ||
| 14 | uint32_t ip; | ||
| 15 | uint64_t shares_accepted; | ||
| 16 | uint64_t shares_rejected; | ||
| 17 | int64_t first_share_time_ms; | ||
| 18 | int64_t last_share_time_ms; | ||
| 19 | double hashrate_ghs; | ||
| 20 | } mining_client_stats_t; | ||
| 21 | |||
| 22 | uint64_t mining_nbits_to_difficulty(uint32_t nbits); | ||
| 23 | double mining_calculate_hashprice(uint32_t nbits); | ||
| 24 | double mining_calculate_hashprice_override(uint64_t sats_per_ghs_day); | ||
| 25 | esp_err_t mining_validate_share(const uint8_t *header80, uint32_t nonce, const uint8_t *target, int target_len); | ||
| 26 | uint64_t mining_shares_to_allotment_ms(double hashrate_ghs, double hashprice_sats_per_ghs_s, int price_per_step, int step_size_ms); | ||
| 27 | uint64_t mining_shares_to_allotment_bytes(double hashrate_ghs, double hashprice_sats_per_ghs_s, int price_per_step, int step_size_bytes); | ||
| 28 | mining_client_stats_t *mining_get_or_create_client(uint32_t client_ip); | ||
| 29 | void mining_update_hashrate(uint32_t client_ip, bool accepted); | ||
| 30 | const mining_client_stats_t *mining_get_client_stats(uint32_t client_ip); | ||
| 31 | double mining_get_current_hashprice(void); | ||
| 32 | void mining_set_current_nbits(uint32_t nbits); | ||
| 33 | void mining_payment_init(void); | ||
| 34 | |||
| 35 | #endif | ||