miner.php allow optional fields when gen is disabled
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
diff --git a/miner.php b/miner.php
index c9bb9cd..5035beb 100644
--- a/miner.php
+++ b/miner.php
@@ -280,14 +280,16 @@ $protoext = array(
'having' => array(array('STATS.Bytes Recv', '>', 0)))
);
#
-# If 'gen' isn't enabled, the 'GEN' fields won't show
+# If 'gen' isn't enabled, the 'GEN' fields won't show but
+# where present, will be replaced with the ||SUMMARY fields
$kanogenpage = array(
'DATE' => null,
'RIGS' => null,
'SUMMARY+COIN' => array('SUMMARY.Elapsed=Elapsed',
'GEN.Mined=Block%', 'GEN.GHS Acc=GH/s Acc',
- 'GEN.GHS WU=GH/s WU', 'GEN.GHS av=GH/s av',
- 'GEN.GHS 5m=GH/s 5m',
+ 'GEN.GHS av=GH/s av||SUMMARY.MHS av=MHS av',
+ 'GEN.GHS 5m=GH/s 5m||SUMMARY.MHS 5m=MHS 5m',
+ 'GEN.GHS WU=GH/s WU||SUMMARY.Work Utility=WU',
'SUMMARY.Found Blocks=Blks',
'SUMMARY.Difficulty Accepted=DiffA',
'SUMMARY.Difficulty Rejected=DiffR',
@@ -304,9 +306,12 @@ $kanogenpage = array(
'Difficulty Stale=DiffS',
'Best Share', 'GEN.Acc=Acc%', 'GEN.Rej=Rej%')
);
+# sum should list all fields seperately including GEN/BGEN || replacements
$kanogensum = array(
- 'SUMMARY+COIN' => array('GEN.Mined', 'GEN.GHS Acc', 'GEN.GHS WU',
- 'GEN.GHS av', 'GEN.GHS 5m',
+ 'SUMMARY+COIN' => array('GEN.Mined', 'GEN.GHS Acc', 'GEN.GHS av',
+ 'GEN.GHS 5m', 'GEN.GHS WU',
+ 'SUMMARY.MHS av', 'SUMMARY.MHS 5m',
+ 'SUMMARY.Work Utility',
'SUMMARY.Found Blocks',
'SUMMARY.Difficulty Accepted',
'SUMMARY.Difficulty Rejected',
@@ -315,6 +320,8 @@ $kanogensum = array(
'POOL' => array('Diff1 Shares', 'Difficulty Accepted',
'Difficulty Rejected', 'Difficulty Stale')
);
+# 'where', 'calc' and 'having' should list GEN/BGEN || replacements seperately
+# 'group' must use the 'name1||name2' format for GEN/BGEN fields
$kanogenext = array(
'SUMMARY+COIN' => array(
'gen' => array('GHS Acc' =>
@@ -494,10 +501,6 @@ $rigips = array();
global $showndate;
$showndate = false;
#
-# For summary page to stop retrying failed rigs
-global $rigerror;
-$rigerror = array();
-#
global $rownum;
$rownum = 0;
#
@@ -545,6 +548,51 @@ function getcsp($name, $systempage = false)
return false;
}
#
+function degenfields(&$sec, $name, $fields)
+{
+ global $allowgen;
+
+ if (!is_array($fields))
+ return;
+
+ foreach ($fields as $num => $fld)
+ if (substr($fld, 0, 5) == 'BGEN.' || substr($fld, 0, 4) == 'GEN.')
+ {
+ $opts = explode('||', $fld, 2);
+ if ($allowgen)
+ {
+ if (count($opts) > 1)
+ $sec[$name][$num] = $opts[0];
+ }
+ else
+ {
+ if (count($opts) > 1)
+ $sec[$name][$num] = $opts[1];
+ else
+ unset($sec[$name][$num]);
+ }
+ }
+}
+#
+# Allow BGEN/GEN fields to have a '||' replacement when gen is disabled
+# N.B. if gen is disabled and all page fields are GBEN/GEN without '||' then
+# the table will disappear
+# Replacements can be in the page fields and then also the ext group fields
+# All other $csp sections should list both separately
+function degen(&$csp)
+{
+ $page = 0;
+ if (isset($csp[$page]) && is_array($csp[$page]))
+ foreach ($csp[$page] as $sec => $fields)
+ degenfields($csp[$page], $sec, $fields);
+
+ $ext = 2;
+ if (isset($csp[$ext]) && is_array($csp[$ext]))
+ foreach ($csp[$ext] as $sec => $types)
+ if (is_array($types) && isset($types['group']))
+ degenfields($types, 'group', $types['group']);
+}
+#
function getcss($cssname, $dom = false)
{
global $colourtable, $colouroverride;
@@ -2640,9 +2688,12 @@ function processext($ext, $section, $res, &$fields)
if ($calc !== null)
foreach ($calc as $field => $func)
{
- if (!isset($interim[$grpkey]['cal'][$field]))
- $interim[$grpkey]['cal'][$field] = array();
- $interim[$grpkey]['cal'][$field][] = $row[$field];
+ if (isset($row[$field]))
+ {
+ if (!isset($interim[$grpkey]['cal'][$field]))
+ $interim[$grpkey]['cal'][$field] = array();
+ $interim[$grpkey]['cal'][$field][] = $row[$field];
+ }
}
}
}
@@ -2878,6 +2929,8 @@ function showcustompage($pagename, $systempage = false)
return;
}
+ degen($csp);
+
$page = $csp[0];
$namemap = array();
foreach ($page as $name => $fields)