mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-04-10 04:49:16 +02:00
free strings first when clearing the ASIC_jobs queue
This commit is contained in:
parent
b14f21c697
commit
0810936b3f
@ -67,9 +67,6 @@ bm_job construct_bm_job(mining_notify * params, const char * merkle_root) {
|
||||
////make the midstate hash
|
||||
uint8_t midstate_data[64];
|
||||
|
||||
//print the header
|
||||
//printf("header: %08x%s%s%08x%08x000000000000008000000000000000000000000000000000000000000000000000000000\n", params->version, params->prev_block_hash, merkle_root, params->ntime, params->target);
|
||||
|
||||
//copy 68 bytes header data into midstate (and deal with endianess)
|
||||
memcpy(midstate_data, &new_job.version, 4); //copy version
|
||||
memcpy(midstate_data + 4, new_job.prev_block_hash, 32); //copy prev_block_hash
|
||||
@ -103,6 +100,8 @@ double test_nonce_value(bm_job * job, uint32_t nonce) {
|
||||
double d64, s64, ds;
|
||||
unsigned char header[80];
|
||||
|
||||
//TODO: use the midstate hash instead of hashing the whole header
|
||||
|
||||
//copy data from job to header
|
||||
memcpy(header, &job->version, 4);
|
||||
memcpy(header + 4, job->prev_block_hash, 32);
|
||||
|
@ -217,7 +217,7 @@ static void create_jobs_task(void * pvParameters)
|
||||
|
||||
if (abandon_work == 1) {
|
||||
abandon_work = 0;
|
||||
queue_clear(&ASIC_jobs_queue);
|
||||
ASIC_jobs_queue_clear(&ASIC_jobs_queue);
|
||||
}
|
||||
|
||||
free_mining_notify(params);
|
||||
@ -305,7 +305,7 @@ static void stratum_task(void * pvParameters)
|
||||
queue_clear(&stratum_queue);
|
||||
|
||||
pthread_mutex_lock(&valid_jobs_lock);
|
||||
queue_clear(&ASIC_jobs_queue);
|
||||
ASIC_jobs_queue_clear(&ASIC_jobs_queue);
|
||||
for (int i = 0; i < 128; i = i + 4) {
|
||||
valid_jobs[i] = 0;
|
||||
}
|
||||
|
@ -56,3 +56,21 @@ void queue_clear(work_queue * queue)
|
||||
pthread_cond_signal(&queue->not_full);
|
||||
pthread_mutex_unlock(&queue->lock);
|
||||
}
|
||||
|
||||
void ASIC_jobs_queue_clear(work_queue * queue)
|
||||
{
|
||||
pthread_mutex_lock(&queue->lock);
|
||||
|
||||
while (queue->count > 0)
|
||||
{
|
||||
bm_job * next_work = queue->buffer[queue->head];
|
||||
free(next_work->jobid);
|
||||
free(next_work->extranonce2);
|
||||
free(next_work);
|
||||
queue->head = (queue->head + 1) % QUEUE_SIZE;
|
||||
queue->count--;
|
||||
}
|
||||
|
||||
pthread_cond_signal(&queue->not_full);
|
||||
pthread_mutex_unlock(&queue->lock);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define WORK_QUEUE_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include "mining.h"
|
||||
|
||||
#define QUEUE_SIZE 12
|
||||
|
||||
@ -17,6 +18,7 @@ typedef struct {
|
||||
|
||||
void queue_init(work_queue * queue);
|
||||
void queue_enqueue(work_queue * queue, void * new_work);
|
||||
void ASIC_jobs_queue_clear(work_queue * queue);
|
||||
void * queue_dequeue(work_queue * queue);
|
||||
void queue_clear(work_queue * queue);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user