Skip to content

Commit

Permalink
api: fix stats gpu mask filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Nov 13, 2014
1 parent 49f3c45 commit 8d6b809
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static char *getsummary(char *params)

*buffer = '\0';
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
"ALGO=%s;KHS=%.2f;ACC=%d;REJ=%d;ACCMN=%.3f;UPTIME=%.1f|",
"ALGO=%s;KHS=%.2f;ACC=%d;REJ=%d;ACCMN=%.3f;UPTIME=%.0f|",
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
algo, (double)global_hashrate / 1000.0,
accepted_count, rejected_count,
Expand Down
12 changes: 6 additions & 6 deletions hashlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ extern "C" uint32_t hashlog_already_submittted(char* jobid, uint32_t nonce)
extern "C" void hashlog_remember_submit(char* jobid, uint32_t nonce, uint32_t scanned_from)
{
uint64_t njobid = hextouint(jobid);
uint64_t keyall = (njobid << 32);
uint64_t key = keyall + nonce;
uint64_t key = (njobid << 32) + nonce;
hashlog_data data;

memset(&data, 0, sizeof(data));
Expand All @@ -80,12 +79,12 @@ extern "C" void hashlog_remember_submit(char* jobid, uint32_t nonce, uint32_t sc
extern "C" void hashlog_remember_scan_range(char* jobid, uint32_t scanned_from, uint32_t scanned_to)
{
uint64_t njobid = hextouint(jobid);
uint64_t keyall = (njobid << 32);
uint64_t key = (njobid << 32);
uint64_t range = hashlog_get_scan_range(jobid);
hashlog_data data;

// global scan range of a job
data = tlastshares[keyall];
data = tlastshares[key];
if (range == 0) {
memset(&data, 0, sizeof(data));
} else {
Expand All @@ -110,7 +109,7 @@ extern "C" void hashlog_remember_scan_range(char* jobid, uint32_t scanned_from,

data.tm_upd = (uint32_t) time(NULL);

tlastshares[keyall] = data;
tlastshares[key] = data;
/* applog(LOG_BLUE, "job %s range : %x %x -> %x %x", jobid,
scanned_from, scanned_to, data.scanned_from, data.scanned_to); */
}
Expand All @@ -124,13 +123,14 @@ extern "C" uint64_t hashlog_get_scan_range(char* jobid)
uint64_t ret = 0;
uint64_t njobid = hextouint(jobid);
uint64_t keypfx = (njobid << 32);
uint64_t keymsk = (UINT_MAX << 32);
hashlog_data data;

data.scanned_from = 0;
data.scanned_to = 0;
std::map<uint64_t, hashlog_data>::iterator i = tlastshares.begin();
while (i != tlastshares.end()) {
if ((keypfx & i->first) == keypfx && i->second.scanned_to > ret) {
if ((keymsk & i->first) == keypfx && i->second.scanned_to > ret) {
if (i->second.scanned_to > data.scanned_to)
data.scanned_to = i->second.scanned_to;
if (i->second.scanned_from < data.scanned_from || data.scanned_from == 0)
Expand Down
3 changes: 2 additions & 1 deletion stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ extern "C" double stats_get_speed(int thr_id)
{
uint64_t thr = (0xff && thr_id);
uint64_t keypfx = (thr << 56);
uint64_t keymsk = (0xff << 56);
double speed = 0.0;
int records = 0;

std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
while (i != tlastscans.rend() && records < opt_statsavg) {
if (!i->second.ignored)
if (thr_id == -1 || (keypfx & i->first) == keypfx) {
if (thr_id == -1 || (keymsk & i->first) == keypfx) {
if (i->second.hashcount > 1000) {
speed += i->second.hashrate;
records++;
Expand Down

0 comments on commit 8d6b809

Please sign in to comment.