Add summary command
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
diff --git a/api.c b/api.c
index bea877d..791029d 100644
--- a/api.c
+++ b/api.c
@@ -189,6 +189,22 @@ char *poolstatus(char *params)
return buffer;
}
+char *summary(char *params)
+{
+ double utility, mhs;
+
+ utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
+ mhs = total_mhashes_done / total_secs;
+
+ sprintf(buffer, "SUMMARY,EL=%.0lf,ALGO=%s,MHS=%.2lf,SOL=%d,Q=%d,A=%d,R=%d,HW=%d,U=%.2lf,DW=%d,ST=%d,GF=%d,LW=%d,RO=%d,BC=%d",
+ total_secs, algo_names[opt_algo], mhs, found_blocks,
+ total_getworks, total_accepted, total_rejected,
+ hw_errors, utility, total_discarded, total_stale,
+ total_go, local_work, total_ro, new_blocks);
+
+ return buffer;
+}
+
char *doquit(char *params)
{
bye = 1;
@@ -203,10 +219,11 @@ struct CMDS {
{ "apiversion", apiversion },
{ "dev", devstatus },
{ "pool", poolstatus },
+ { "summary", summary },
{ "quit", doquit },
};
-#define CMDMAX 4
+#define CMDMAX 5
void send_result(int c, char *result)
{
diff --git a/main.c b/main.c
index d2f794b..fd0d8a3 100644
--- a/main.c
+++ b/main.c
@@ -99,18 +99,6 @@ struct workio_cmd {
bool lagging;
};
-enum sha256_algos {
- ALGO_C, /* plain C */
- ALGO_4WAY, /* parallel SSE2 */
- ALGO_VIA, /* VIA padlock */
- ALGO_CRYPTOPP, /* Crypto++ (C) */
- ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
- ALGO_SSE2_32, /* SSE2 for x86_32 */
- ALGO_SSE2_64, /* SSE2 for x86_64 */
- ALGO_SSE4_64, /* SSE4 for x86_64 */
- ALGO_ALTIVEC_4WAY, /* parallel Altivec */
-};
-
enum pool_strategy {
POOL_FAILOVER,
POOL_ROUNDROBIN,
@@ -131,7 +119,7 @@ struct strategies {
static size_t max_name_len = 0;
static char *name_spaces_pad = NULL;
-static const char *algo_names[] = {
+const char *algo_names[] = {
[ALGO_C] = "c",
#ifdef WANT_SSE2_4WAY
[ALGO_4WAY] = "4way",
@@ -209,11 +197,11 @@ int opt_bench_algo = -1;
static const bool opt_time = true;
static bool opt_restart = true;
#if defined(WANT_X8664_SSE2) && defined(__SSE2__)
-static enum sha256_algos opt_algo = ALGO_SSE2_64;
+enum sha256_algos opt_algo = ALGO_SSE2_64;
#elif defined(WANT_X8632_SSE2) && defined(__SSE2__)
-static enum sha256_algos opt_algo = ALGO_SSE2_32;
+enum sha256_algos opt_algo = ALGO_SSE2_32;
#else
-static enum sha256_algos opt_algo = ALGO_C;
+enum sha256_algos opt_algo = ALGO_C;
#endif
static int nDevs;
static int opt_g_threads = 2;
@@ -258,21 +246,21 @@ static pthread_mutex_t qd_lock;
static pthread_mutex_t *stgd_lock;
static pthread_mutex_t curses_lock;
static pthread_rwlock_t blk_lock;
-static double total_mhashes_done;
+double total_mhashes_done;
static struct timeval total_tv_start, total_tv_end;
pthread_mutex_t control_lock;
int hw_errors;
-static int total_accepted, total_rejected;
-static int total_getworks, total_stale, total_discarded;
+int total_accepted, total_rejected;
+int total_getworks, total_stale, total_discarded;
static int total_queued;
-static unsigned int new_blocks;
+unsigned int new_blocks;
static unsigned int work_block;
-static unsigned int found_blocks;
+unsigned int found_blocks;
-static unsigned int local_work;
-static unsigned int total_go, total_ro;
+unsigned int local_work;
+unsigned int total_go, total_ro;
struct pool *pools[MAX_POOLS];
static struct pool *currentpool = NULL;
diff --git a/miner.h b/miner.h
index 8430ccc..ea81a2a 100644
--- a/miner.h
+++ b/miner.h
@@ -156,6 +156,19 @@ enum {
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
+enum sha256_algos {
+ ALGO_C, /* plain C */
+ ALGO_4WAY, /* parallel SSE2 */
+ ALGO_VIA, /* VIA padlock */
+ ALGO_CRYPTOPP, /* Crypto++ (C) */
+ ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
+ ALGO_SSE2_32, /* SSE2 for x86_32 */
+ ALGO_SSE2_64, /* SSE2 for x86_64 */
+ ALGO_SSE4_64, /* SSE4 for x86_64 */
+ ALGO_ALTIVEC_4WAY, /* parallel Altivec */
+};
+
+
enum alive {
LIFE_WELL,
LIFE_SICK,
@@ -415,6 +428,15 @@ extern int mining_threads;
extern struct cgpu_info *cpus;
extern int total_pools;
extern struct pool *pools[MAX_POOLS];
+extern const char *algo_names[];
+extern enum sha256_algos opt_algo;
+extern double total_mhashes_done;
+extern unsigned int new_blocks;
+extern unsigned int found_blocks;
+extern int total_accepted, total_rejected;
+extern int total_getworks, total_stale, total_discarded;
+extern unsigned int local_work;
+extern unsigned int total_go, total_ro;
#ifdef HAVE_OPENCL
typedef struct {