craigwatson / bitcoind-status

PHP application to display status and information from the Bitcoin node daemon.
https://odin.vikingserv.net
Apache License 2.0
82 stars 77 forks source link

Some updates for you: Graphs, latency and node height percentage. #57

Open mcjoshea opened 4 years ago

mcjoshea commented 4 years ago

Hi Craig,

I really like your application. I particularly like the simplicity of the display and the clarity of the information you've chosen to show.

I guess you've not done much with it since last year. I installed the application recently and came across a number of bugs which I fixed for my own setup, so thought you might like to know what I had to do.

To get the graphs to work I had to change template.html from this:

  <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
  <script type="text/javascript">

to this:

  <script src="https://www.gstatic.com/charts/loader.js?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
  <script>
  google.charts.load('current', {packages: ['corechart']});
  google.charts.setOnLoadCallback(drawChart);

To get the latency to display correctly I had to alter functions.php from this:

    // Get node info from bitnodes.earn.com
    if ($config['display_bitnodes_info'] === true) {
        $data['bitnodes_info'] = json_decode(curlRequest("https://bitnodes.earn.com/api/v1/nodes/" . $data['node_ip'] . "-8333/", $bitnodes_curl), true);
        $latency = json_decode(curlRequest("https://bitnodes.earn.com/api/v1/nodes/" . $data['node_ip'] . "-8333/latency/", $bitnodes_curl), true);
        $data['bitnodes_info']['latest_latency'] = $latency['daily_latency'][0]['v'];
    }

To this:

    // Get node info from bitnodes.io
    if ($config['display_bitnodes_info'] === true) {
        $data['bitnodes_info'] = json_decode(curlRequest("https://bitnodes.io/api/v1/nodes/" . $data['node_ip'] . "-8333/", $bitnodes_curl), true);
        $latency = json_decode(curlRequest("https://bitnodes.io/api/v1/nodes/" . $data['node_ip'] . "-8333/latency/", $bitnodes_curl), true);
        $data['bitnodes_info']['latest_latency'] = $latency['daily_latency'][0]['v'];
    }

To get the node height percentage to show correctly I had to remove this from functions.php:

 // Get max height from bitnodes.earn.com
    if ($config['display_max_height'] === true) {
        if ($config['display_testnet'] === true) {
            $exec_result = json_decode(curlRequest("https://chain.so/api/v2/get_info/BTCTEST", $bitnodes_curl), true);
        } else {
            $exec_result = json_decode(curlRequest("https://chain.so/api/v2/get_info/BTC", $bitnodes_curl), true);
        }
        $data['max_height'] = $exec_result['data']['blocks'];
        $data['node_height_percent'] = round(($data['blocks']/$data['max_height'])*100, 1);
    }   

and replace it with this:

$data['node_height_percent'] = round(($data['verificationprogress'])*100, 1);

Hope this helps!

Cheers Mark

craigwatson commented 4 years ago

Hi Mark,

Thanks for the comments - it’s true that the project hasn’t been worked on in recent months as I’ve retired by Bitcoin nodes, so it’s not unsurprising that there are some bugs :)

However, please do feel free to fork the project and contribute your fixes via a Pull Request - I’m unlikely to make any changes myself as I have no way of verifying or testing them at the moment.

Thanks, Craig