bitfury_work_to_payload is double handling the data unnecessarily
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/libbitfury.c b/libbitfury.c
index 37861f0..f712183 100644
--- a/libbitfury.c
+++ b/libbitfury.c
@@ -133,19 +133,16 @@ static int rehash(unsigned char *midstate, unsigned m7, unsigned ntime, unsigned
return 0;
}
-void bitfury_work_to_payload(struct bitfury_payload *p, struct work *w)
+void bitfury_work_to_payload(struct bitfury_payload *p, struct work *work)
{
- unsigned char flipped_data[80];
-
- memset(p, 0, sizeof(struct bitfury_payload));
- flip80(flipped_data, w->data);
-
- memcpy(p->midstate, w->midstate, 32);
- p->m7 = bswap_32(*(unsigned *)(flipped_data + 64));
- p->ntime = bswap_32(*(unsigned *)(flipped_data + 68));
- p->nbits = bswap_32(*(unsigned *)(flipped_data + 72));
- applog(LOG_INFO, "INFO nonc: %08x bitfury_scanHash MS0: %08x, ", p->nnonce, ((unsigned int *)w->midstate)[0]);
- applog(LOG_INFO, "INFO merkle[7]: %08x, ntime: %08x, nbits: %08x", p->m7, p->ntime, p->nbits);
+ memcpy(p->midstate, work->midstate, 32);
+ p->m7 = *(unsigned int *)(work->data + 64);
+ p->ntime = *(unsigned int *)(work->data + 68);
+ p->nbits = *(unsigned int *)(work->data + 72);
+ applog(LOG_INFO, "INFO nonc: %08x bitfury_scanHash MS0: %08x, ", p->nnonce,
+ ((unsigned int *)work->midstate)[0]);
+ applog(LOG_INFO, "INFO merkle[7]: %08x, ntime: %08x, nbits: %08x", p->m7,
+ p->ntime, p->nbits);
}
/* Configuration registers - control oscillators and such stuff. PROGRAMMED when
diff --git a/libbitfury.h b/libbitfury.h
index b3c99ed..3ac1fff 100644
--- a/libbitfury.h
+++ b/libbitfury.h
@@ -14,7 +14,7 @@
void ms3steps(uint32_t *p);
uint32_t decnonce(uint32_t in);
-void bitfury_work_to_payload(struct bitfury_payload *p, struct work *w);
+void bitfury_work_to_payload(struct bitfury_payload *p, struct work *work);
void spi_set_freq(struct bitfury_info *info);
void spi_send_conf(struct bitfury_info *info);
void spi_send_init(struct bitfury_info *info);