Send per-core hashrates at regular ~5min intervals back to cta devices.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
diff --git a/driver-cointerra.c b/driver-cointerra.c
index 0fab09d..8a2ef98 100644
--- a/driver-cointerra.c
+++ b/driver-cointerra.c
@@ -11,6 +11,7 @@
#include "miner.h"
#include "driver-cointerra.h"
+#include <math.h>
static const char *cointerra_hdr = "ZZ";
@@ -935,6 +936,31 @@ static void cta_zero_corehashes(struct cointerra_info *info)
cgtime(&info->core_hash_start);
}
+/* Send per core hashrate calculations at regular intervals ~every 5 minutes */
+static void cta_send_corehashes(struct cgpu_info *cointerra, struct cointerra_info *info,
+ double corehash_time)
+{
+ uint16_t core_ghs[CTA_CORES];
+ double k[CTA_CORES];
+ char buf[CTA_MSG_SIZE];
+ int i, offset;
+
+ for (i = 0; i < CTA_CORES; i++) {
+ k[i] = (double)info->tot_core_hashes[i] / ((double)32 * (double)0x100000000ull);
+ k[i] = sqrt(k[i]) + 1;
+ k[i] *= k[i];
+ k[i] = k[i] * 32 * ((double)0x100000000ull / (double)1000000000) / corehash_time;
+ core_ghs[i] = k[i];
+ }
+ cta_gen_message(buf, CTA_SEND_COREHASHRATE);
+ offset = CTA_CORE_HASHRATES;
+ for (i = 0; i < CTA_CORES; i++) {
+ msg_from_hu16(buf, offset, core_ghs[i]);
+ offset += 2; // uint16_t
+ }
+ cta_send_msg(cointerra, buf);
+}
+
static int64_t cta_scanwork(struct thr_info *thr)
{
struct cgpu_info *cointerra = thr->cgpu;
@@ -997,6 +1023,7 @@ static int64_t cta_scanwork(struct thr_info *thr)
corehash_time = tdiff(&now, &info->core_hash_start);
if (corehash_time > 300) {
+ cta_send_corehashes(cointerra, info, corehash_time);
cta_zero_corehashes(info);
}
diff --git a/driver-cointerra.h b/driver-cointerra.h
index 1acdf37..e989cf5 100644
--- a/driver-cointerra.h
+++ b/driver-cointerra.h
@@ -48,6 +48,7 @@
#define CTA_WORK_NROLL 53
#define CTA_WORK_DIFFBITS 55
#define CTA_REQWORK_REQUESTS 3
+#define CTA_CORE_HASHRATES 3
/* Received message types */
#define CTA_RECV_UNUSED 0
@@ -69,6 +70,7 @@
#define CTA_SEND_REQUEST 4
#define CTA_SEND_FMATCH 5
#define CTA_SEND_IDENTIFY 6
+#define CTA_SEND_COREHASHRATE 7
/* Types of reset in CTA_RESET_TYPE */
#define CTA_RESET_NONE 0