Skip to content

Commit 5b62629

Browse files
committed
more logs
1 parent d5919b7 commit 5b62629

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/main.cu

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ std::mutex write_mutex;
6060
uint8_t write_buffer[4096 * 1024];
6161
void submit_new_block(mining_worker_t *worker)
6262
{
63-
expire_template_for_new_block(load_worker__template(worker));
63+
mining_template_t *template_ptr = load_worker__template(worker);
64+
int height = template_ptr->job->height;
65+
int from_group = template_ptr->job->from_group;
66+
int to_group = template_ptr->job->to_group;
67+
expire_template_for_new_block(template_ptr);
6468

6569
const std::lock_guard<std::mutex> lock(write_mutex);
6670

6771
ssize_t buf_size = write_new_block(worker, write_buffer);
6872
uv_buf_t buf = uv_buf_init((char *)write_buffer, buf_size);
69-
print_hex("new solution", (uint8_t *) hasher_buf(worker, true), 32);
73+
print_hex_with_info("new solution", (uint8_t *) hasher_hash(worker, true), 32, height, from_group, to_group);
7074

7175
uv_write_t *write_req = (uv_write_t *)malloc(sizeof(uv_write_t));
7276
uint32_t buf_count = 1;

src/messages.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ 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)
44+
{
45+
char *hex_string = bytes_to_hex(data, nread);
46+
LOG("%s: %d -> %d, height: %d, hash: %s\n", prefix, from, to, height, hex_string);
47+
free(hex_string);
48+
}
49+
4350
void print_hex(const char* prefix, uint8_t *data, ssize_t nread)
4451
{
4552
char *hex_string = bytes_to_hex(data, nread);

src/template.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +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);
7879
}
7980

8081
bool expire_template_for_new_block(mining_template_t *template_ptr)

src/worker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +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);
201203
add_template__ref_count(template_ptr, 1);
202204
store_worker__template(worker, template_ptr);
203205
}

0 commit comments

Comments
 (0)