|
|
@ -871,6 +871,18 @@ K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, |
|
|
|
return ws_item; |
|
|
|
return ws_item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// workerstatus must be locked
|
|
|
|
|
|
|
|
static void zero_on_idle(tv_t *when, WORKERSTATUS *workerstatus) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
copy_tv(&(workerstatus->active_start), when); |
|
|
|
|
|
|
|
workerstatus->active_diffacc = workerstatus->active_diffinv = |
|
|
|
|
|
|
|
workerstatus->active_diffsta = workerstatus->active_diffdup = |
|
|
|
|
|
|
|
workerstatus->active_diffhi = workerstatus->active_diffrej = |
|
|
|
|
|
|
|
workerstatus->active_shareacc = workerstatus->active_shareinv = |
|
|
|
|
|
|
|
workerstatus->active_sharesta = workerstatus->active_sharedup = |
|
|
|
|
|
|
|
workerstatus->active_sharehi = workerstatus->active_sharerej = 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* All data is loaded, now update workerstatus fields
|
|
|
|
/* All data is loaded, now update workerstatus fields
|
|
|
|
TODO: combine set_block_share_counters() with this? */ |
|
|
|
TODO: combine set_block_share_counters() with this? */ |
|
|
|
void workerstatus_ready() |
|
|
|
void workerstatus_ready() |
|
|
@ -939,6 +951,8 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, |
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
if (tv_newer(&(row->last_auth), &(auths->createdate))) |
|
|
|
if (tv_newer(&(row->last_auth), &(auths->createdate))) |
|
|
|
copy_tv(&(row->last_auth), &(auths->createdate)); |
|
|
|
copy_tv(&(row->last_auth), &(auths->createdate)); |
|
|
|
|
|
|
|
if (row->active_start.tv_sec == 0) |
|
|
|
|
|
|
|
copy_tv(&(row->active_start), &(auths->createdate)); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -960,34 +974,54 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, |
|
|
|
copy_tv(&(row->last_share), &(shares->createdate)); |
|
|
|
copy_tv(&(row->last_share), &(shares->createdate)); |
|
|
|
row->last_diff = shares->diff; |
|
|
|
row->last_diff = shares->diff; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (row->active_start.tv_sec == 0) |
|
|
|
|
|
|
|
copy_tv(&(row->active_start), &(shares->createdate)); |
|
|
|
switch (shares->errn) { |
|
|
|
switch (shares->errn) { |
|
|
|
case SE_NONE: |
|
|
|
case SE_NONE: |
|
|
|
row->diffacc += shares->diff; |
|
|
|
row->block_diffacc += shares->diff; |
|
|
|
row->shareacc++; |
|
|
|
row->block_shareacc++; |
|
|
|
|
|
|
|
row->active_diffacc += shares->diff; |
|
|
|
|
|
|
|
row->active_shareacc++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SE_STALE: |
|
|
|
case SE_STALE: |
|
|
|
row->diffinv += shares->diff; |
|
|
|
row->block_diffinv += shares->diff; |
|
|
|
row->shareinv++; |
|
|
|
row->block_shareinv++; |
|
|
|
row->diffsta += shares->diff; |
|
|
|
row->block_diffsta += shares->diff; |
|
|
|
row->sharesta++; |
|
|
|
row->block_sharesta++; |
|
|
|
|
|
|
|
row->active_diffinv += shares->diff; |
|
|
|
|
|
|
|
row->active_shareinv++; |
|
|
|
|
|
|
|
row->active_diffsta += shares->diff; |
|
|
|
|
|
|
|
row->active_sharesta++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SE_DUPE: |
|
|
|
case SE_DUPE: |
|
|
|
row->diffinv += shares->diff; |
|
|
|
row->block_diffinv += shares->diff; |
|
|
|
row->shareinv++; |
|
|
|
row->block_shareinv++; |
|
|
|
row->diffdup += shares->diff; |
|
|
|
row->block_diffdup += shares->diff; |
|
|
|
row->sharedup++; |
|
|
|
row->block_sharedup++; |
|
|
|
|
|
|
|
row->active_diffinv += shares->diff; |
|
|
|
|
|
|
|
row->active_shareinv++; |
|
|
|
|
|
|
|
row->active_diffdup += shares->diff; |
|
|
|
|
|
|
|
row->active_sharedup++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SE_HIGH_DIFF: |
|
|
|
case SE_HIGH_DIFF: |
|
|
|
row->diffinv += shares->diff; |
|
|
|
row->block_diffinv += shares->diff; |
|
|
|
row->shareinv++; |
|
|
|
row->block_shareinv++; |
|
|
|
row->diffhi += shares->diff; |
|
|
|
row->block_diffhi += shares->diff; |
|
|
|
row->sharehi++; |
|
|
|
row->block_sharehi++; |
|
|
|
|
|
|
|
row->active_diffinv += shares->diff; |
|
|
|
|
|
|
|
row->active_shareinv++; |
|
|
|
|
|
|
|
row->active_diffhi += shares->diff; |
|
|
|
|
|
|
|
row->active_sharehi++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
row->diffinv += shares->diff; |
|
|
|
row->block_diffinv += shares->diff; |
|
|
|
row->shareinv++; |
|
|
|
row->block_shareinv++; |
|
|
|
row->diffrej += shares->diff; |
|
|
|
row->block_diffrej += shares->diff; |
|
|
|
row->sharerej++; |
|
|
|
row->block_sharerej++; |
|
|
|
|
|
|
|
row->active_diffinv += shares->diff; |
|
|
|
|
|
|
|
row->active_shareinv++; |
|
|
|
|
|
|
|
row->active_diffrej += shares->diff; |
|
|
|
|
|
|
|
row->active_sharerej++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
@ -1001,8 +1035,10 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, |
|
|
|
DATA_WORKERSTATUS(row, item); |
|
|
|
DATA_WORKERSTATUS(row, item); |
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
if (userstats->idle) { |
|
|
|
if (userstats->idle) { |
|
|
|
if (tv_newer(&(row->last_idle), &(userstats->statsdate))) |
|
|
|
if (tv_newer(&(row->last_idle), &(userstats->statsdate))) { |
|
|
|
copy_tv(&(row->last_idle), &(userstats->statsdate)); |
|
|
|
copy_tv(&(row->last_idle), &(userstats->statsdate)); |
|
|
|
|
|
|
|
zero_on_idle(&(userstats->statsdate), row); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (tv_newer(&(row->last_stats), &(userstats->statsdate))) |
|
|
|
if (tv_newer(&(row->last_stats), &(userstats->statsdate))) |
|
|
|
copy_tv(&(row->last_stats), &(userstats->statsdate)); |
|
|
|
copy_tv(&(row->last_stats), &(userstats->statsdate)); |
|
|
@ -2436,12 +2472,12 @@ void zero_on_new_block() |
|
|
|
ws_item = first_in_ktree(workerstatus_root, ctx); |
|
|
|
ws_item = first_in_ktree(workerstatus_root, ctx); |
|
|
|
while (ws_item) { |
|
|
|
while (ws_item) { |
|
|
|
DATA_WORKERSTATUS(workerstatus, ws_item); |
|
|
|
DATA_WORKERSTATUS(workerstatus, ws_item); |
|
|
|
workerstatus->diffacc = workerstatus->diffinv = |
|
|
|
workerstatus->block_diffacc = workerstatus->block_diffinv = |
|
|
|
workerstatus->diffsta = workerstatus->diffdup = |
|
|
|
workerstatus->block_diffsta = workerstatus->block_diffdup = |
|
|
|
workerstatus->diffhi = workerstatus->diffrej = |
|
|
|
workerstatus->block_diffhi = workerstatus->block_diffrej = |
|
|
|
workerstatus->shareacc = workerstatus->shareinv = |
|
|
|
workerstatus->block_shareacc = workerstatus->block_shareinv = |
|
|
|
workerstatus->sharesta = workerstatus->sharedup = |
|
|
|
workerstatus->block_sharesta = workerstatus->block_sharedup = |
|
|
|
workerstatus->sharehi = workerstatus->sharerej = 0.0; |
|
|
|
workerstatus->block_sharehi = workerstatus->block_sharerej = 0.0; |
|
|
|
ws_item = next_in_ktree(ctx); |
|
|
|
ws_item = next_in_ktree(ctx); |
|
|
|
} |
|
|
|
} |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
@ -2511,20 +2547,25 @@ void set_block_share_counters() |
|
|
|
pool.diffacc += sharesummary->diffacc; |
|
|
|
pool.diffacc += sharesummary->diffacc; |
|
|
|
pool.diffinv += sharesummary->diffsta + sharesummary->diffdup + |
|
|
|
pool.diffinv += sharesummary->diffsta + sharesummary->diffdup + |
|
|
|
sharesummary->diffhi + sharesummary->diffrej; |
|
|
|
sharesummary->diffhi + sharesummary->diffrej; |
|
|
|
workerstatus->diffacc += sharesummary->diffacc; |
|
|
|
// Block stats only
|
|
|
|
workerstatus->diffinv += sharesummary->diffsta + sharesummary->diffdup + |
|
|
|
workerstatus->block_diffacc += sharesummary->diffacc; |
|
|
|
sharesummary->diffhi + sharesummary->diffrej; |
|
|
|
workerstatus->block_diffinv += sharesummary->diffsta + |
|
|
|
workerstatus->diffsta += sharesummary->diffsta; |
|
|
|
sharesummary->diffdup + |
|
|
|
workerstatus->diffdup += sharesummary->diffdup; |
|
|
|
sharesummary->diffhi + |
|
|
|
workerstatus->diffhi += sharesummary->diffhi; |
|
|
|
sharesummary->diffrej; |
|
|
|
workerstatus->diffrej += sharesummary->diffrej; |
|
|
|
workerstatus->block_diffsta += sharesummary->diffsta; |
|
|
|
workerstatus->shareacc += sharesummary->shareacc; |
|
|
|
workerstatus->block_diffdup += sharesummary->diffdup; |
|
|
|
workerstatus->shareinv += sharesummary->sharesta + sharesummary->sharedup + |
|
|
|
workerstatus->block_diffhi += sharesummary->diffhi; |
|
|
|
sharesummary->sharehi + sharesummary->sharerej; |
|
|
|
workerstatus->block_diffrej += sharesummary->diffrej; |
|
|
|
workerstatus->sharesta += sharesummary->sharesta; |
|
|
|
workerstatus->block_shareacc += sharesummary->shareacc; |
|
|
|
workerstatus->sharedup += sharesummary->sharedup; |
|
|
|
workerstatus->block_shareinv += sharesummary->sharesta + |
|
|
|
workerstatus->sharehi += sharesummary->sharehi; |
|
|
|
sharesummary->sharedup + |
|
|
|
workerstatus->sharerej += sharesummary->sharerej; |
|
|
|
sharesummary->sharehi + |
|
|
|
|
|
|
|
sharesummary->sharerej; |
|
|
|
|
|
|
|
workerstatus->block_sharesta += sharesummary->sharesta; |
|
|
|
|
|
|
|
workerstatus->block_sharedup += sharesummary->sharedup; |
|
|
|
|
|
|
|
workerstatus->block_sharehi += sharesummary->sharehi; |
|
|
|
|
|
|
|
workerstatus->block_sharerej += sharesummary->sharerej; |
|
|
|
|
|
|
|
|
|
|
|
ss_item = prev_in_ktree(ctx); |
|
|
|
ss_item = prev_in_ktree(ctx); |
|
|
|
} |
|
|
|
} |
|
|
@ -2589,20 +2630,25 @@ void set_block_share_counters() |
|
|
|
pool.diffacc += markersummary->diffacc; |
|
|
|
pool.diffacc += markersummary->diffacc; |
|
|
|
pool.diffinv += markersummary->diffsta + markersummary->diffdup + |
|
|
|
pool.diffinv += markersummary->diffsta + markersummary->diffdup + |
|
|
|
markersummary->diffhi + markersummary->diffrej; |
|
|
|
markersummary->diffhi + markersummary->diffrej; |
|
|
|
workerstatus->diffacc += markersummary->diffacc; |
|
|
|
// Block stats only
|
|
|
|
workerstatus->diffinv += markersummary->diffsta + markersummary->diffdup + |
|
|
|
workerstatus->block_diffacc += markersummary->diffacc; |
|
|
|
markersummary->diffhi + markersummary->diffrej; |
|
|
|
workerstatus->block_diffinv += markersummary->diffsta + |
|
|
|
workerstatus->diffsta += markersummary->diffsta; |
|
|
|
markersummary->diffdup + |
|
|
|
workerstatus->diffdup += markersummary->diffdup; |
|
|
|
markersummary->diffhi + |
|
|
|
workerstatus->diffhi += markersummary->diffhi; |
|
|
|
markersummary->diffrej; |
|
|
|
workerstatus->diffrej += markersummary->diffrej; |
|
|
|
workerstatus->block_diffsta += markersummary->diffsta; |
|
|
|
workerstatus->shareacc += markersummary->shareacc; |
|
|
|
workerstatus->block_diffdup += markersummary->diffdup; |
|
|
|
workerstatus->shareinv += markersummary->sharesta + markersummary->sharedup + |
|
|
|
workerstatus->block_diffhi += markersummary->diffhi; |
|
|
|
markersummary->sharehi + markersummary->sharerej; |
|
|
|
workerstatus->block_diffrej += markersummary->diffrej; |
|
|
|
workerstatus->sharesta += markersummary->sharesta; |
|
|
|
workerstatus->block_shareacc += markersummary->shareacc; |
|
|
|
workerstatus->sharedup += markersummary->sharedup; |
|
|
|
workerstatus->block_shareinv += markersummary->sharesta + |
|
|
|
workerstatus->sharehi += markersummary->sharehi; |
|
|
|
markersummary->sharedup + |
|
|
|
workerstatus->sharerej += markersummary->sharerej; |
|
|
|
markersummary->sharehi + |
|
|
|
|
|
|
|
markersummary->sharerej; |
|
|
|
|
|
|
|
workerstatus->block_sharesta += markersummary->sharesta; |
|
|
|
|
|
|
|
workerstatus->block_sharedup += markersummary->sharedup; |
|
|
|
|
|
|
|
workerstatus->block_sharehi += markersummary->sharehi; |
|
|
|
|
|
|
|
workerstatus->block_sharerej += markersummary->sharerej; |
|
|
|
|
|
|
|
|
|
|
|
ms_item = prev_in_ktree(ctx_ms); |
|
|
|
ms_item = prev_in_ktree(ctx_ms); |
|
|
|
} |
|
|
|
} |
|
|
|