mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-29 11:11:45 +01:00
update system hashrate on every chip share, not just pool shares. (#196)
This commit is contained in:
parent
11c1d087a8
commit
4bda726f38
@ -324,8 +324,9 @@ static uint8_t _send_init(uint64_t frequency)
|
||||
_send_simple(init10, 11);
|
||||
|
||||
//set ticket mask
|
||||
unsigned char init11[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
|
||||
_send_simple(init11, 11);
|
||||
// unsigned char init11[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
|
||||
// _send_simple(init11, 11);
|
||||
BM1368_set_job_difficulty_mask(BM1368_INITIAL_DIFFICULTY);
|
||||
|
||||
//Analog Mux Control
|
||||
unsigned char init12[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x1D};
|
||||
@ -426,11 +427,9 @@ int BM1368_set_max_baud(void)
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
|
||||
void BM1368_set_job_difficulty_mask(int difficulty)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
// Default mask of 256 diff
|
||||
unsigned char job_difficulty_mask[9] = {0x00, TICKET_MASK, 0b00000000, 0b00000000, 0b00000000, 0b11111111};
|
||||
|
||||
@ -452,7 +451,7 @@ void BM1368_set_job_difficulty_mask(int difficulty)
|
||||
job_difficulty_mask[5 - i] = _reverse_bits(value);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Setting job ASIC mask to %d", difficulty);
|
||||
ESP_LOGI(TAG, "Setting ASIC difficulty mask to %d", difficulty);
|
||||
|
||||
_send_BM1368((TYPE_CMD | GROUP_ALL | CMD_WRITE), job_difficulty_mask, 6, false);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mining.h"
|
||||
|
||||
#define CRC5_MASK 0x1F
|
||||
#define BM1366_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t BM1366_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1366_CORE_COUNT = 672;
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#define CRC5_MASK 0x1F
|
||||
|
||||
#define BM1368_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t BM1368_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1368_CORE_COUNT = 672;
|
||||
// static const uint64_t BM1368_HASHRATE_S = BM1368_FREQUENCY * BM1368_CORE_COUNT * 1000000;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mining.h"
|
||||
|
||||
#define CRC5_MASK 0x1F
|
||||
#define BM1397_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t ASIC_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1397_CORE_COUNT = 672;
|
||||
|
@ -28,6 +28,7 @@ typedef struct
|
||||
char * asic_model;
|
||||
AsicFunctions ASIC_functions;
|
||||
double asic_job_frequency_ms;
|
||||
uint32_t initial_ASIC_difficulty;
|
||||
|
||||
work_queue stratum_queue;
|
||||
work_queue ASIC_jobs_queue;
|
||||
|
@ -37,6 +37,7 @@ void app_main(void)
|
||||
.set_difficulty_mask_fn = BM1366_set_job_difficulty_mask,
|
||||
.send_work_fn = BM1366_send_work};
|
||||
GLOBAL_STATE.asic_job_frequency_ms = BM1366_FULLSCAN_MS;
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1366_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
} else if (strcmp(GLOBAL_STATE.asic_model, "BM1368") == 0) {
|
||||
@ -49,6 +50,7 @@ void app_main(void)
|
||||
|
||||
uint64_t bm1368_hashrate = GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1368_CORE_COUNT * 1000000;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = ((double) NONCE_SPACE / (double) bm1368_hashrate) * 1000;
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1368_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
} else if (strcmp(GLOBAL_STATE.asic_model, "BM1397") == 0) {
|
||||
@ -61,6 +63,7 @@ void app_main(void)
|
||||
|
||||
uint64_t bm1397_hashrate = GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1397_CORE_COUNT * 1000000;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = ((double) NONCE_SPACE / (double) bm1397_hashrate) * 1000;
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1397_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
} else {
|
||||
|
@ -432,7 +432,6 @@ void SYSTEM_notify_new_ntime(SystemModule * module, uint32_t ntime)
|
||||
void SYSTEM_notify_found_nonce(SystemModule * module, double pool_diff, double found_diff, uint32_t nbits, float power)
|
||||
{
|
||||
// Calculate the time difference in seconds with sub-second precision
|
||||
|
||||
// hashrate = (nonce_difficulty * 2^32) / time_to_find
|
||||
|
||||
module->historical_hashrate[module->historical_hashrate_rolling_index] = pool_diff;
|
||||
|
@ -53,9 +53,10 @@ void ASIC_result_task(void *pvParameters)
|
||||
asic_result->nonce,
|
||||
asic_result->rolled_version ^ GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->version);
|
||||
|
||||
SYSTEM_notify_found_nonce(&GLOBAL_STATE->SYSTEM_MODULE, GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->pool_diff,
|
||||
nonce_diff, GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->target,
|
||||
GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power);
|
||||
}
|
||||
|
||||
SYSTEM_notify_found_nonce(&GLOBAL_STATE->SYSTEM_MODULE, GLOBAL_STATE->initial_ASIC_difficulty,
|
||||
nonce_diff, GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->target,
|
||||
GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power);
|
||||
}
|
||||
}
|
@ -34,8 +34,8 @@ void ASIC_task(void *pvParameters)
|
||||
|
||||
if (next_bm_job->pool_diff != GLOBAL_STATE->stratum_difficulty)
|
||||
{
|
||||
// ESP_LOGI(TAG, "New difficulty %d", next_bm_job->pool_diff);
|
||||
(*GLOBAL_STATE->ASIC_functions.set_difficulty_mask_fn)(next_bm_job->pool_diff);
|
||||
ESP_LOGI(TAG, "New pool difficulty %lu", next_bm_job->pool_diff);
|
||||
//(*GLOBAL_STATE->ASIC_functions.set_difficulty_mask_fn)(next_bm_job->pool_diff);
|
||||
GLOBAL_STATE->stratum_difficulty = next_bm_job->pool_diff;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user