Browse Source

Merge branch 'master' into multiproxy

master
Con Kolivas 10 years ago
parent
commit
83f99bdb75
  1. 19
      pool/page.php
  2. 2
      pool/prime.php
  3. 2
      src/ckpool.c
  4. 4
      src/ckpool.h
  5. 18
      src/stratifier.c

19
pool/page.php

@ -205,8 +205,8 @@ function ni(e,o){if(e){if(o==0){e.defd=e.style.display;e.style.display='none'}el
function domin(o){var e=document.getElementById('minicb');if(e){if(o==0){e.checked=true}else{e.checked=false}};for(var i=0;i<10;i++){e=document.getElementById('mini'+i);ni(e,o)}} function domin(o){var e=document.getElementById('minicb');if(e){if(o==0){e.checked=true}else{e.checked=false}};for(var i=0;i<10;i++){e=document.getElementById('mini'+i);ni(e,o)}}
function mini(){var hm=gcn('mini');if(hm==''){domin(1)}else{domin(0)}} function mini(){var hm=gcn('mini');if(hm==''){domin(1)}else{domin(0)}}
function md(e){var c='';if(e.checked){c='y'}scnv('mini',c);mini()} function md(e){var c='';if(e.checked){c='y'}scnv('mini',c);mini()}
function tim(){var e=document.getElementById('ftr');if(e){var now=new Date(),t=document.createTextNode(now.toLocaleString());e.appendChild(t)}}
function jst(){var e=document.getElementById('jst');if(e){e.style.visibility='hidden'}} function jst(){var e=document.getElementById('jst');if(e){e.style.visibility='hidden'}}
window.onpaint=jst();
</script>\n"; </script>\n";
$head .= "<style type='text/css'> $head .= "<style type='text/css'>
input[type=checkbox] {vertical-align: -2px;} input[type=checkbox] {vertical-align: -2px;}
@ -245,7 +245,7 @@ if (!$iCrap)
} }
$head .= " $head .= "
h1 {margin-top: 20px; float:middle; font-size: 20px;} h1 {margin-top: 20px; float:middle; font-size: 20px;}
.foot, .push {height: 50px; font-size: 10pt;} .foot, .push {height: 50px;}
.title {background-color: #909090;} .title {background-color: #909090;}
.even {background-color: #cccccc;} .even {background-color: #cccccc;}
.odd {background-color: #a8a8a8;} .odd {background-color: #a8a8a8;}
@ -263,6 +263,9 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;}
.fthi {color:red; font-size:7px; } .fthi {color:red; font-size:7px; }
.ftlo {color:green; font-size:7px; } .ftlo {color:green; font-size:7px; }
.ft {color:blue; font-size:7px; } .ft {color:blue; font-size:7px; }
.ftl {text-align: left; color:blue; font-size:7px; display:inline-block; width:20%; white-space: nowrap; }
.ftm {text-align: middle; font-size:10pt; display:inline-block; width:60%; white-space: nowrap; }
.ftr {text-align: rigth; color:blue; font-size:7px; display:inline-block; width:20%; white-space: nowrap; }
$css_marker $css_marker
</style>\n"; </style>\n";
@ -589,7 +592,7 @@ function pgmenu($menus)
# #
function pgbody($info, $page, $menu, $dotop, $user, $douser) function pgbody($info, $page, $menu, $dotop, $user, $douser)
{ {
$body = '<body onload="mini();jst()"'; $body = '<body';
if ($page == 'index') if ($page == 'index')
$body .= ' background=/BTC20.png'; $body .= ' background=/BTC20.png';
$body .= '><div class=page>'; $body .= '><div class=page>';
@ -613,12 +616,14 @@ function pgbody($info, $page, $menu, $dotop, $user, $douser)
# #
function pgfoot($info) function pgfoot($info)
{ {
global $stt;
$foot = '</div></td></tr>'; $foot = '</div></td></tr>';
$foot .= '</table>'; $foot .= '</table>';
$foot .= '</center></td></tr>'; $foot .= '</center></td></tr>';
$foot .= '</table>'; $foot .= '</table>';
$foot .= '<div class=push></div></div>'; $foot .= '<div class=push></div></div>';
$foot .= '<div class=foot><br>'; $std = gmdate('jS M H:i:s \U\T\C', intval($stt));
$foot .= "<div class=foot><br><span class=ftl>$std&nbsp;</span><span class=ftm>";
if (is_array($info) && isset($info['sync'])) if (is_array($info) && isset($info['sync']))
{ {
$sync = $info['sync']; $sync = $info['sync'];
@ -627,14 +632,14 @@ function pgfoot($info)
else else
$syc = 'lo'; $syc = 'lo';
$syncd = number_format($sync); $syncd = number_format($sync);
$foot .= "<span class=ft$syc>sync: $syncd</span> "; $foot .= "<span class=ft$syc>sync: $syncd</span>&nbsp;";
} }
$foot .= 'Copyright &copy; Kano 2014'; $foot .= 'Copyright &copy; Kano 2014';
$now = date('Y'); $now = date('Y');
if ($now != '2014') if ($now != '2014')
$foot .= "-$now"; $foot .= "-$now";
$foot .= ' <span class=ft>Z/s</span></div>'; $foot .= '&nbsp;<span class=ft>Z/s</span></span><span class=ftr id=ftr>&nbsp;</span></div>';
$foot .= "</body></html>\n"; $foot .= "<script type='text/javascript'>jst();tim();mini();</script></body></html>\n";
return $foot; return $foot;
} }

2
pool/prime.php

@ -1,7 +1,7 @@
<?php <?php
# #
global $stt; global $stt;
$stt = microtime(); $stt = microtime(true);
# #
global $loginfailed; global $loginfailed;
$loginfailed = false; $loginfailed = false;

2
src/ckpool.c

@ -1438,6 +1438,8 @@ int main(int argc, char **argv)
global_ckp = &ckp; global_ckp = &ckp;
memset(&ckp, 0, sizeof(ckp)); memset(&ckp, 0, sizeof(ckp));
ckp.starttime = time(NULL);
ckp.startpid = getpid();
ckp.loglevel = LOG_NOTICE; ckp.loglevel = LOG_NOTICE;
ckp.initial_args = ckalloc(sizeof(char *) * (argc + 2)); /* Leave room for extra -H */ ckp.initial_args = ckalloc(sizeof(char *) * (argc + 2)); /* Leave room for extra -H */
for (ckp.args = 0; ckp.args < argc; ckp.args++) for (ckp.args = 0; ckp.args < argc; ckp.args++)

4
src/ckpool.h

@ -99,6 +99,10 @@ struct server_instance {
typedef struct server_instance server_instance_t; typedef struct server_instance server_instance_t;
struct ckpool_instance { struct ckpool_instance {
/* Start time */
time_t starttime;
/* Start pid */
pid_t startpid;
/* The initial command line arguments */ /* The initial command line arguments */
char **initial_args; char **initial_args;
/* Number of arguments */ /* Number of arguments */

18
src/stratifier.c

@ -401,9 +401,9 @@ struct stratifier_data {
/* Protects sequence numbers */ /* Protects sequence numbers */
mutex_t ckdb_msg_lock; mutex_t ckdb_msg_lock;
/* Incrementing global sequence number */ /* Incrementing global sequence number */
int ckdb_seq; uint64_t ckdb_seq;
/* Incrementing ckdb_ids[] sequence numbers */ /* Incrementing ckdb_ids[] sequence numbers */
int ckdb_seq_ids[ID_COUNT]; uint64_t ckdb_seq_ids[ID_COUNT];
bool ckdb_offline; bool ckdb_offline;
bool verbose; bool verbose;
@ -682,17 +682,21 @@ static char *ckdb_msg(ckpool_t *ckp, sdata_t *sdata, json_t *val, const int idty
char *json_msg; char *json_msg;
char logname[512]; char logname[512];
char *ret = NULL; char *ret = NULL;
uint64_t seqall;
/* Set the atomically incrementing sequence number */ json_set_int(val, "seqstart", ckp->starttime);
json_set_int(val, "seqpid", ckp->startpid);
/* Set the atomically incrementing sequence numbers */
mutex_lock(&sdata->ckdb_msg_lock); mutex_lock(&sdata->ckdb_msg_lock);
json_set_int(val, "seqall", sdata->ckdb_seq++); seqall = sdata->ckdb_seq++;
json_set_int(val, "seqall", seqall);
json_set_int(val, ckdb_seq_names[idtype], sdata->ckdb_seq_ids[idtype]++); json_set_int(val, ckdb_seq_names[idtype], sdata->ckdb_seq_ids[idtype]++);
mutex_unlock(&sdata->ckdb_msg_lock); mutex_unlock(&sdata->ckdb_msg_lock);
json_msg = json_dumps(val, JSON_COMPACT); json_msg = json_dumps(val, JSON_COMPACT);
if (unlikely(!json_msg)) if (unlikely(!json_msg))
goto out; goto out;
ASPRINTF(&ret, "%s.id.json=%s", ckdb_ids[idtype], json_msg); ASPRINTF(&ret, "%s.%"PRIu64".json=%s", ckdb_ids[idtype], seqall, json_msg);
free(json_msg); free(json_msg);
out: out:
json_decref(val); json_decref(val);
@ -3815,7 +3819,7 @@ static int send_recv_auth(stratum_instance_t *client)
LOGINFO("Got ckdb response: %s", buf); LOGINFO("Got ckdb response: %s", buf);
response = alloca(responselen); response = alloca(responselen);
memset(response, 0, responselen); memset(response, 0, responselen);
if (unlikely(sscanf(buf, "id.%*d.%c%n", response, &offset) < 1)) { if (unlikely(sscanf(buf, "%*d.%*d.%c%n", response, &offset) < 1)) {
LOGWARNING("Got1 unparseable ckdb auth response: %s", buf); LOGWARNING("Got1 unparseable ckdb auth response: %s", buf);
goto out_fail; goto out_fail;
} }
@ -5248,7 +5252,7 @@ static void ckdbq_process(ckpool_t *ckp, char *msg)
int offset = 0; int offset = 0;
memset(response, 0, responselen); memset(response, 0, responselen);
if (sscanf(buf, "id.%*d.%c%n", response, &offset) > 0) { if (sscanf(buf, "%*d.%*d.%c%n", response, &offset) > 0) {
strcpy(response+1, buf+offset); strcpy(response+1, buf+offset);
if (safecmp(response, "ok")) { if (safecmp(response, "ok")) {
char *cmd; char *cmd;

Loading…
Cancel
Save