Skip to content

Commit 7585964

Browse files
committed
wip
1 parent 46e0c40 commit 7585964

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/messages.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ typedef struct job_t {
7979
blob_t header_blob;
8080
blob_t txs_blob;
8181
blob_t target;
82+
blob_t uncle_blob;
8283
} job_t;
8384

8485
void free_job(job_t *job) {
8586
free_blob(&job->header_blob);
8687
free_blob(&job->txs_blob);
8788
free_blob(&job->target);
89+
if (job->uncle_blob.len > 0) {
90+
free_blob(&job->uncle_blob);
91+
}
8892
free(job);
8993
}
9094

@@ -210,6 +214,18 @@ void extract_blob(uint8_t **bytes, blob_t *blob)
210214
// LOG("%s\n", bytes_to_hex(blob->blob, blob->len));
211215
}
212216

217+
void extract_uncle_blob(uint8_t **bytes, blob_t *blob)
218+
{
219+
uint8_t flag = *bytes[0];
220+
*bytes = *bytes + 1;
221+
if (flag == 1) {
222+
extract_blob(bytes, blob);
223+
} else {
224+
blob->len = 0;
225+
blob->blob = NULL;
226+
}
227+
}
228+
213229
void extract_job(uint8_t **bytes, job_t *job)
214230
{
215231
job->from_group = extract_size(bytes);
@@ -218,6 +234,7 @@ void extract_job(uint8_t **bytes, job_t *job)
218234
extract_blob(bytes, &job->header_blob);
219235
extract_blob(bytes, &job->txs_blob);
220236
extract_blob(bytes, &job->target);
237+
extract_uncle_blob(bytes, &job->uncle_blob);
221238
}
222239

223240
void extract_jobs(uint8_t **bytes, jobs_t *jobs)

src/worker.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ ssize_t write_new_block(mining_worker_t *worker, uint8_t *write_buf) {
183183
: worker->host_hasher.ref_hasher->buf;
184184
uint8_t *write_pos = write_buf;
185185

186-
ssize_t block_size = 24 + job->header_blob.len + job->txs_blob.len;
186+
ssize_t block_size = 24 + job->header_blob.len + job->txs_blob.len + job->uncle_blob.len;
187187
ssize_t message_size = 1 + 4 + block_size;
188188

189189
write_size(&write_pos, message_size);
@@ -192,6 +192,9 @@ ssize_t write_new_block(mining_worker_t *worker, uint8_t *write_buf) {
192192
write_bytes(&write_pos, nonce, 24);
193193
write_blob(&write_pos, &job->header_blob);
194194
write_blob(&write_pos, &job->txs_blob);
195+
if (job->uncle_blob.len > 0) {
196+
write_blob(&write_pos, &job->uncle_blob);
197+
}
195198

196199
return message_size + 4;
197200
}

0 commit comments

Comments
 (0)