Skip to content

Instantly share code, notes, and snippets.

@GeertJohan
Created October 11, 2015 20:12
Show Gist options
  • Save GeertJohan/81407ab9316902dd3113 to your computer and use it in GitHub Desktop.
Save GeertJohan/81407ab9316902dd3113 to your computer and use it in GitHub Desktop.
echo '<div class="seeds">';
function humanHashrate($value, $dec = 2) {
$size = array('H/s', 'kH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s', 'ZH/s', 'YH/s');
$factor = floor((strlen($value) - 1) / 3);
return sprintf("%.{$dec}f", $value / pow(1024, $factor)) .' '. @$size[$factor];
}
$json = file_get_contents('https://seeds.gulden.com/service/seedsOverview');
$data = json_decode($json, true);
foreach( $data['nodes'] as $node ) {
$versionMajor = round(substr($node['version'], 0, strlen($node['version'])-6));
$versionMinor = round(substr($node['version'], strlen($node['version'])-6, 2));
$versionPatch = round(substr($node['version'], strlen($node['version'])-4, 2));
$versionBuild = round(substr($node['version'], strlen($node['version'])-2, 2));
$version = $versionMajor.'.'.$versionMinor.'.'.$versionPatch;
if($versionBuild != 0) {
$version .= '.'.$versionBuild;
}
echo '
<div class="seeds-row">
<div class="seeds-status seeds-status-'.$node['status'].'">'.$node['status'].'</div>
<div class="seeds-hostname">'.$node['hostname'].'</div>
<div class="seeds-version">'.$version.'</div>
<div class="seeds-connections">'.$node['connections'].'</div>
<div class="seeds-hashrate">'.humanHashrate($node['hashrate'], 3).'</div>
<div class="seeds-difficulty">'.round($node['difficulty'], 2).'</div>
<div class="seeds-height">
<a href="https://explorer.gulden.com/#/block/'.$node['blockHash'].'" target="_blank">'.$node['blockNumber'].'</a>
</div>
<div class="seeds-blockHash">
<span style="font-family: monospace;" >'.substr($node['blockHash'], 0, 15).'</span>
</div>
</div>';
}
echo '</div>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment