Skip to content

Commit 5fe43a8

Browse files
committed
wip
1 parent 5b62629 commit 5fe43a8

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/main.cu

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void submit_new_block(mining_worker_t *worker)
7070

7171
ssize_t buf_size = write_new_block(worker, write_buffer);
7272
uv_buf_t buf = uv_buf_init((char *)write_buffer, buf_size);
73-
print_hex_with_info("new solution", (uint8_t *) hasher_hash(worker, true), 32, height, from_group, to_group);
73+
print_hex_with_info("new solution", (uint8_t *) hasher_hash(worker, true), 32, height, from_group, to_group, worker->id);
7474

7575
uv_write_t *write_req = (uv_write_t *)malloc(sizeof(uv_write_t));
7676
uint32_t buf_count = 1;
@@ -128,14 +128,16 @@ void after_mine(uv_work_t *req, int status)
128128
void worker_stream_callback(cudaStream_t stream, cudaError_t status, void *data)
129129
{
130130
mining_worker_t *worker = (mining_worker_t *)data;
131+
mining_template_t *template_ptr = load_worker__template(worker);
132+
job_t *job = template_ptr->job;
131133
if (hasher_found_good_hash(worker, true))
132134
{
133135
store_worker_found_good_hash(worker, true);
134136
submit_new_block(worker);
137+
} else {
138+
// LOG("Not found good hash: %d -> %d, height: %d, worker: %d\n", job->from_group, job->to_group, job->height, worker->id);
135139
}
136140

137-
mining_template_t *template_ptr = load_worker__template(worker);
138-
job_t *job = template_ptr->job;
139141
uint32_t chain_index = job->from_group * group_nums + job->to_group;
140142
mining_counts[chain_index].fetch_sub(mining_steps);
141143
mining_counts[chain_index].fetch_add(hasher_hash_count(worker, true));
@@ -249,6 +251,8 @@ void try_to_reconnect(uv_timer_t *timer){
249251
uv_timer_stop(timer);
250252
}
251253

254+
int job_counts = 0;
255+
252256
void on_read(uv_stream_t *server, ssize_t nread, const uv_buf_t *buf)
253257
{
254258
if (nread < 0)
@@ -263,12 +267,15 @@ void on_read(uv_stream_t *server, ssize_t nread, const uv_buf_t *buf)
263267
return;
264268
}
265269

270+
LOG("=========== job conts %d\n", job_counts);
271+
266272
server_message_t *message = decode_buf(buf, nread);
267273
if (message)
268274
{
269275
switch (message->kind)
270276
{
271277
case JOBS:
278+
job_counts += 1;
272279
for (int i = 0; i < message->jobs->len; i++)
273280
{
274281
update_templates(message->jobs->jobs[i]);

src/messages.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ char *bytes_to_hex(uint8_t *bytes, ssize_t len)
4040
return hex_string;
4141
}
4242

43-
void print_hex_with_info(const char* prefix, uint8_t *data, ssize_t nread, int height, int from, int to)
43+
void print_hex_with_info(const char* prefix, uint8_t *data, ssize_t nread, int height, int from, int to, int worker_id)
4444
{
4545
char *hex_string = bytes_to_hex(data, nread);
46-
LOG("%s: %d -> %d, height: %d, hash: %s\n", prefix, from, to, height, hex_string);
46+
LOG("%s: %d -> %d, height: %d, hash: %s, worker: %d\n", prefix, from, to, height, hex_string, worker_id);
4747
free(hex_string);
4848
}
4949

@@ -240,6 +240,7 @@ void extract_jobs(uint8_t **bytes, jobs_t *jobs)
240240
jobs->len = jobs_size;
241241
jobs->jobs = (job_t **)malloc(jobs_size * sizeof(job_t*));
242242
for(ssize_t i = 0; i < jobs_size; i++) {
243+
// jobs->jobs[i] = NULL;
243244
jobs->jobs[i] = (job_t *)malloc(sizeof(job_t));
244245
extract_job(bytes, (jobs->jobs[i]));
245246
}

src/template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void update_templates(job_t *job)
7575
free_template(last_template);
7676
}
7777
store_template(chain_index, new_template);
78-
LOG("Store new job: %d -> %d, height: %d\n", job->from_group, job->to_group, job->height);
78+
// LOG("Store new job: %d -> %d, height: %d\n", job->from_group, job->to_group, job->height);
7979
}
8080

8181
bool expire_template_for_new_block(mining_template_t *template_ptr)

src/worker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ ssize_t write_new_block(mining_worker_t *worker, uint8_t *write_buf) {
198198
}
199199

200200
void setup_template(mining_worker_t *worker, mining_template_t *template_ptr) {
201-
LOG("Start mining job: %d -> %d, height: %d, worker: %d\n",
202-
template_ptr->job->from_group, template_ptr->job->to_group, template_ptr->job->height, worker->id);
201+
// LOG("Start mining job: %d -> %d, height: %d, worker: %d\n",
202+
// template_ptr->job->from_group, template_ptr->job->to_group, template_ptr->job->height, worker->id);
203203
add_template__ref_count(template_ptr, 1);
204204
store_worker__template(worker, template_ptr);
205205
}

0 commit comments

Comments
 (0)