Skip to content

Instantly share code, notes, and snippets.

@bakavic
Created September 7, 2017 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakavic/a68f1cd56e40e2040011f254ed9671eb to your computer and use it in GitHub Desktop.
Save bakavic/a68f1cd56e40e2040011f254ed9671eb to your computer and use it in GitHub Desktop.
Simple PHP page to view all your dwarfpool workers and addresses on 1 page
<?php
// Add as many addresses (and email that was associated) here
$accts = [
[
"address" => "0x967de65f15763181a9914ddb0b04cc53474329fa",
"email" => "me@example.com"
]
];
$url = "http://dwarfpool.com/eth/api?";
foreach ($accts as $acc) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $url . "wallet=" . $acc['address'] . "&email=" . $acc['email']);
$result=curl_exec($ch);
curl_close($ch);
$response = json_decode($result, true);
echo "<h3>Wallet: " . $response['wallet'] . "</h3>";
echo "<b>Balance: " . $response['wallet_balance'] . " ETH</b><br>";
echo "<b>Email: " . substr_replace($acc['email'],'*****',2,5) . "</b>";
echo "<h3>Workers states:</h3>";
foreach($response['workers'] as $worker) {
echo "<b>" . $worker['worker'] ."</b>";
if (! $worker['alive']) echo '<b style="colour:red;">WORKER DOWN!</b>';
$utc_date = DateTime::createFromFormat(
"D, d M Y H:i:s T",
$worker['last_submit']
);
$sgt_date = clone $utc_date;
$sgt_date->setTimeZone(new DateTimeZone('Asia/Singapore'));
echo "<ul>
<li>Alive: " . $worker['alive'] . "</li>
<li>Hashrate: " . $worker['hashrate'] . " MH/s</li>
<li>Below Threshold: " . $worker['hashrate_below_threshold'] . "</li>
<li>Cal hashrate: " . $worker['hashrate_calculated'] . " MH/s</li>
<li>Last Submitted: " . $sgt_date->format("D, d M Y H:i:s T") . "</li>
</ul>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment