Commit 84428a038a9fd8980af7fb2efdb70e9afe2a832a

Con Kolivas 2014-01-09T12:46:14

bitfury_work_to_payload is double handling the data unnecessarily

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);