@@ 106-122 (lines=17) @@ | ||
103 | * @param limit int Last limit blocks |
|
104 | * @return array |
|
105 | **/ |
|
106 | public function getBlocksFound($limit=10) { |
|
107 | $this->debug->append("STA " . __METHOD__, 4); |
|
108 | if ($data = $this->memcache->get(__FUNCTION__ . $limit)) return $data; |
|
109 | $stmt = $this->mysqli->prepare(" |
|
110 | SELECT |
|
111 | b.*, |
|
112 | a.username AS finder, |
|
113 | a.is_anonymous AS is_anonymous, |
|
114 | ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), " . $this->coin->getShareDifficultyPrecision() . ") AS estshares |
|
115 | FROM " . $this->block->getTableName() . " AS b |
|
116 | LEFT JOIN " . $this->user->getTableName() . " AS a |
|
117 | ON b.account_id = a.id |
|
118 | ORDER BY height DESC LIMIT ?"); |
|
119 | if ($this->checkStmt($stmt) && $stmt->bind_param("i", $limit) && $stmt->execute() && $result = $stmt->get_result()) |
|
120 | return $this->memcache->setCache(__FUNCTION__ . $limit, $result->fetch_all(MYSQLI_ASSOC), 5); |
|
121 | return $this->sqlError(); |
|
122 | } |
|
123 | ||
124 | /** |
|
125 | * Get our last $limit blocks found by height |
|
@@ 257-278 (lines=22) @@ | ||
254 | * @param none |
|
255 | * @return data object Our share rate in shares per second |
|
256 | **/ |
|
257 | public function getCurrentShareRate($interval=180) { |
|
258 | $this->debug->append("STA " . __METHOD__, 4); |
|
259 | if ($data = $this->memcache->getStatic(__FUNCTION__)) return $data; |
|
260 | $stmt = $this->mysqli->prepare(" |
|
261 | SELECT |
|
262 | ( |
|
263 | ( |
|
264 | SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate |
|
265 | FROM " . $this->share->getTableName() . " |
|
266 | WHERE time > DATE_SUB(now(), INTERVAL ? SECOND) |
|
267 | AND our_result = 'Y' |
|
268 | ) + ( |
|
269 | SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate |
|
270 | FROM " . $this->share->getArchiveTableName() . " |
|
271 | WHERE time > DATE_SUB(now(), INTERVAL ? SECOND) |
|
272 | AND our_result = 'Y' |
|
273 | ) |
|
274 | ) AS sharerate |
|
275 | FROM DUAL"); |
|
276 | if ($this->checkStmt($stmt) && $stmt->bind_param('iiii', $interval, $interval, $interval, $interval) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setStaticCache(__FUNCTION__, $result->fetch_object()->sharerate); |
|
277 | return $this->sqlError(); |
|
278 | } |
|
279 | ||
280 | /** |
|
281 | * Get total shares for this round, since last block found |