Browse Source

Move/rename _ssm_gen_dummy_work to work2d_gen_dummy_work

Luke Dashjr 12 years ago
parent
commit
d6031db052
3 changed files with 30 additions and 25 deletions
  1. 1 25
      driver-stratum.c
  2. 27 0
      work2d.c
  3. 2 0
      work2d.h

+ 1 - 25
driver-stratum.c

@@ -67,31 +67,7 @@ struct stratumsrv_conn {
 
 static struct stratumsrv_conn *_ssm_connections;
 
-static
-void _ssm_gen_dummy_work(struct work * const work, struct stratum_work * const swork, const struct timeval * const tvp_prepared, const char * const extranonce2, const uint32_t xnonce1)
-{
-	uint8_t *p, *s;
-	
-	*work = (struct work){
-		.pool = swork->pool,
-		.work_restart_id = swork->work_restart_id,
-		.tv_staged = *tvp_prepared,
-	};
-	bytes_resize(&work->nonce2, swork->n2size);
-	s = bytes_buf(&work->nonce2);
-	p = &s[swork->n2size - _ssm_client_xnonce2sz];
-	if (extranonce2)
-		hex2bin(p, extranonce2, _ssm_client_xnonce2sz);
-#ifndef __OPTIMIZE__
-	else
-		memset(p, '\0', _ssm_client_xnonce2sz);
-#endif
-	p -= _ssm_client_octets;
-	memcpy(p, &xnonce1, _ssm_client_octets);
-	if (p != s)
-		memset(s, '\xbb', p - s);
-	gen_stratum_work2(work, swork);
-}
+#define _ssm_gen_dummy_work work2d_gen_dummy_work
 
 static
 bool stratumsrv_update_notify_str(struct pool * const pool, bool clean)

+ 27 - 0
work2d.c

@@ -11,8 +11,10 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "miner.h"
+#include "util.h"
 
 #define MAX_DIVISIONS 255
 
@@ -45,3 +47,28 @@ void release_work2d_(uint32_t xnonce1)
 	xnonce1 = le32toh(xnonce1);
 	work2d_reserved[xnonce1] = false;
 }
+
+void work2d_gen_dummy_work(struct work * const work, struct stratum_work * const swork, const struct timeval * const tvp_prepared, const char * const extranonce2, const uint32_t xnonce1)
+{
+	uint8_t *p, *s;
+	
+	*work = (struct work){
+		.pool = swork->pool,
+		.work_restart_id = swork->work_restart_id,
+		.tv_staged = *tvp_prepared,
+	};
+	bytes_resize(&work->nonce2, swork->n2size);
+	s = bytes_buf(&work->nonce2);
+	p = &s[swork->n2size - work2d_xnonce2sz];
+	if (extranonce2)
+		hex2bin(p, extranonce2, work2d_xnonce2sz);
+#ifndef __OPTIMIZE__
+	else
+		memset(p, '\0', work2d_xnonce2sz);
+#endif
+	p -= work2d_xnonce1sz;
+	memcpy(p, &xnonce1, work2d_xnonce1sz);
+	if (p != s)
+		memset(s, '\xbb', p - s);
+	gen_stratum_work2(work, swork);
+}

+ 2 - 0
work2d.h

@@ -11,4 +11,6 @@ extern void work2d_init();
 extern bool reserve_work2d_(uint32_t *xnonce1_p);
 extern void release_work2d_(uint32_t xnonce1);
 
+extern void work2d_gen_dummy_work(struct work *, struct stratum_work *, const struct timeval *tvp_prepared, const char *extranonce2, uint32_t xnonce1);
+
 #endif