| @@ 161-183 (lines=23) @@ | ||
| 158 | * @param height int Block Height |
|
| 159 | * @return data array Block round transactions |
|
| 160 | **/ |
|
| 161 | public function getAllRoundTransactions($iHeight=0) { |
|
| 162 | $this->debug->append("STA " . __METHOD__, 4); |
|
| 163 | $stmt = $this->mysqli->prepare(" |
|
| 164 | SELECT |
|
| 165 | t.id AS id, |
|
| 166 | a.id AS uid, |
|
| 167 | a.username AS username, |
|
| 168 | a.is_anonymous, |
|
| 169 | t.type AS type, |
|
| 170 | t.amount AS amount |
|
| 171 | FROM " . $this->transaction->getTableName() . " AS t |
|
| 172 | LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id |
|
| 173 | LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id |
|
| 174 | WHERE b.height = ? AND t.type = 'Credit' |
|
| 175 | ORDER BY amount DESC"); |
|
| 176 | if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result()) |
|
| 177 | return $result->fetch_all(MYSQLI_ASSOC); |
|
| 178 | $this->debug->append('Unable to fetch transactions'); |
|
| 179 | return $this->sqlError(); |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * Get transactions for round block height user id |
|
| 184 | * @param height int Block Height |
|
| 185 | * @param id int user id |
|
| 186 | * @return data array Block round transactions for user id |
|
| @@ 188-208 (lines=21) @@ | ||
| 185 | * @param id int user id |
|
| 186 | * @return data array Block round transactions for user id |
|
| 187 | **/ |
|
| 188 | public function getUserRoundTransactions($iHeight=0, $id=0) { |
|
| 189 | $this->debug->append("STA " . __METHOD__, 4); |
|
| 190 | $stmt = $this->mysqli->prepare(" |
|
| 191 | SELECT |
|
| 192 | t.id AS id, |
|
| 193 | a.username AS username, |
|
| 194 | t.type AS type, |
|
| 195 | t.amount AS amount |
|
| 196 | FROM " . $this->transaction->getTableName() . " AS t |
|
| 197 | LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id |
|
| 198 | LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id |
|
| 199 | WHERE b.height = ? AND a.id = ? |
|
| 200 | ORDER BY id ASC"); |
|
| 201 | if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $iHeight, $id) && $stmt->execute() && $result = $stmt->get_result()) |
|
| 202 | return $result->fetch_all(MYSQLI_ASSOC); |
|
| 203 | $this->debug->append('Unable to fetch transactions'); |
|
| 204 | return $this->sqlError(); |
|
| 205 | } |
|
| 206 | ||
| 207 | /** |
|
| 208 | * Get ALL last blocks from height for admin panel |
|
| 209 | **/ |
|
| 210 | public function getAllReportBlocksFoundHeight($iHeight=0, $limit=10) { |
|
| 211 | $stmt = $this->mysqli->prepare(" |
|
| @@ 261-277 (lines=17) @@ | ||
| 258 | /** |
|
| 259 | * Get credit transactions for round block height for admin panel |
|
| 260 | **/ |
|
| 261 | public function getUserRoundTransHeight($iHeight=0, $iUser) { |
|
| 262 | $this->debug->append("STA " . __METHOD__, 4); |
|
| 263 | $stmt = $this->mysqli->prepare(" |
|
| 264 | SELECT |
|
| 265 | IFNULL(t.amount, 0) AS amount |
|
| 266 | FROM " . $this->transaction->getTableName() . " AS t |
|
| 267 | LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id |
|
| 268 | LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id |
|
| 269 | WHERE b.height = ? AND t.type = 'Credit' AND t.account_id = ?"); |
|
| 270 | if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $iHeight, $iUser) && $stmt->execute() && $result = $stmt->get_result()) |
|
| 271 | return $result->fetch_object()->amount; |
|
| 272 | $this->debug->append('Unable to fetch transactions'); |
|
| 273 | return $this->sqlError(); |
|
| 274 | } |
|
| 275 | } |
|
| 276 | ||
| 277 | $roundstats = new RoundStats(); |
|
| 278 | $roundstats->setDebug($debug); |
|
| 279 | $roundstats->setMysql($mysqli); |
|
| 280 | $roundstats->setConfig($config); |
|
| @@ 58-95 (lines=38) @@ | ||
| 55 | * @param none |
|
| 56 | * @return data array Workers in IDLE state and monitoring enabled |
|
| 57 | **/ |
|
| 58 | public function getAllIdleWorkers($interval=600) { |
|
| 59 | $this->debug->append("STA " . __METHOD__, 4); |
|
| 60 | $stmt = $this->mysqli->prepare(" |
|
| 61 | SELECT w.account_id AS account_id, w.id AS id, w.username AS username |
|
| 62 | FROM |
|
| 63 | ( |
|
| 64 | SELECT username AS s_username, MAX(shares_id) AS shares_id, MAX(shares_archive_id) AS shares_archive_id |
|
| 65 | FROM |
|
| 66 | ( |
|
| 67 | SELECT |
|
| 68 | s.username AS username, MAX(s.id) AS shares_id, NULL AS shares_archive_id |
|
| 69 | FROM . " . $this->share->getTableName() . " AS s |
|
| 70 | WHERE s.time > DATE_SUB(now(), INTERVAL ? SECOND) |
|
| 71 | AND s.our_result = 'Y' |
|
| 72 | GROUP BY s.username |
|
| 73 | UNION |
|
| 74 | SELECT |
|
| 75 | sa.username AS username, NULL AS shares_id, MAX(sa.id) AS shares_archive_id |
|
| 76 | FROM " . $this->share->getArchiveTableName() . " AS sa |
|
| 77 | WHERE sa.time > DATE_SUB(now(), INTERVAL ? SECOND) |
|
| 78 | AND sa.our_result = 'Y' |
|
| 79 | GROUP BY sa.username |
|
| 80 | ) AS derived0 |
|
| 81 | GROUP BY s_username |
|
| 82 | ) AS derived1 |
|
| 83 | RIGHT JOIN " . $this->getTableName() . " AS w |
|
| 84 | ON s_username = w.username |
|
| 85 | WHERE w.monitor = 1 |
|
| 86 | AND shares_id IS NULL |
|
| 87 | AND shares_archive_id IS NULL |
|
| 88 | "); |
|
| 89 | if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $interval, $interval) && $stmt->execute() && $result = $stmt->get_result()) |
|
| 90 | return $result->fetch_all(MYSQLI_ASSOC); |
|
| 91 | return $this->sqlError('E0054'); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * Fetch a specific worker and its status |
|
| 96 | * @param id int Worker ID |
|
| 97 | * @return mixed array Worker details |
|
| 98 | **/ |
|