Skip to content

Commit 9c82fe1

Browse files
committed
Add api call icon
1 parent 0f72f30 commit 9c82fe1

4 files changed

Lines changed: 58 additions & 60 deletions

File tree

src/Content.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,45 @@
33
namespace App;
44

55
function createMainContent(){
6-
$peersInfo = getPeerData();
7-
$peerCount = count($peersInfo["peers"]);
8-
$banListInfo = createBanListContent();
9-
10-
$content = [];
11-
$content['bannedPeers'] = $banListInfo['totalBans'];
12-
$content['last24h'] = $banListInfo['lastCount'];
13-
$content['node'] = new Node();
14-
if(Config::PEERS_GEO){
15-
$content['map'] = createMapJs($peerCount, $peersInfo['countryList']);
16-
}
17-
$content['geo'] = Config::PEERS_GEO;
18-
$content['nPeers'] = $peersInfo["newPeersCount"];
19-
$content['chartData'] = getTopClients($peersInfo["peers"]);
20-
21-
// Current peers traffic
22-
$content['cTrafficIn'] = round($peersInfo["cTrafficIn"]/1000, 2);
23-
$content['cTrafficOut'] = round($peersInfo["cTrafficOut"]/1000, 2);
24-
25-
return $content;
6+
$peersData = getPeerData();
7+
$peerCount = count($peersData["peers"]);
8+
$banListInfo = createBanListContent();
9+
10+
$content = [];
11+
$content['bannedPeers'] = $banListInfo['totalBans'];
12+
$content['last24h'] = $banListInfo['lastCount'];
13+
$content['node'] = new Node();
14+
$content['geo'] = Config::PEERS_GEO;
15+
if(isset($peersData['countryList'])) $content['map'] = createMapJs($peerCount, $peersData['countryList']);
16+
if(isset($peersData['api'])) $content['api'] = $peersData['api'];
17+
$content['nPeers'] = $peersData["newPeersCount"];
18+
$content['chartData'] = getTopClients($peersData["peers"]);
19+
20+
// Current peers traffic
21+
$content['cTrafficIn'] = round($peersData["cTrafficIn"]/1000, 2);
22+
$content['cTrafficOut'] = round($peersData["cTrafficOut"]/1000, 2);
23+
24+
return $content;
2625
}
2726

2827
function createPeerContent(){
2928
global $bitcoind;
3029

31-
$peersInfo = getPeerData();
30+
$peersData = getPeerData();
3231
$netinfo = $bitcoind->getnettotals();
33-
$content = getMostPop($peersInfo["peers"]);
34-
$content['peers'] = $peersInfo["peers"];
35-
$content['tPeers'] = count($peersInfo["peers"]);
36-
$content['nPeers'] = $peersInfo["newPeersCount"];
32+
$content = getMostPop($peersData["peers"]);
33+
$content['peers'] = $peersData["peers"];
34+
$content['tPeers'] = count($peersData["peers"]);
35+
$content['nPeers'] = $peersData["newPeersCount"];
3736
//$content['segWitP'] = round($content['segWitC']/($content['tPeers'] > 0 ? $content['tPeers'] : 1),2)*100;
38-
$content['cTraffic'] = round($peersInfo["cTraffic"]/1000,2);
39-
$content['cTrafficIn'] = round($peersInfo["cTrafficIn"]/1000, 2);
40-
$content['cTrafficOut'] = round($peersInfo["cTrafficOut"]/1000, 2);
37+
$content['cTraffic'] = round($peersData["cTraffic"]/1000,2);
38+
$content['cTrafficIn'] = round($peersData["cTrafficIn"]/1000, 2);
39+
$content['cTrafficOut'] = round($peersData["cTrafficOut"]/1000, 2);
4140
$content['tTraffic'] = round(($netinfo["totalbytesrecv"] + $netinfo["totalbytessent"])/1000000000,2);
4241
$content['tTrafficOutP'] = round(($netinfo["totalbytessent"]/($netinfo["totalbytesrecv"] + $netinfo["totalbytessent"])),2)*100;
4342
$content['cTrafficP'] = round($content['cTraffic']/($content['tTraffic'] > 0 ? $content['tTraffic'] : 1),2)*100;
4443
$content['geo'] = Config::PEERS_GEO;
44+
if(isset($peersData['api'])) $content['api'] = $peersData['api'];
4545

4646
return $content;
4747
}

src/Utility.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -479,16 +479,16 @@ function getPeerData(bool $geo = CONFIG::PEERS_GEO){
479479
}
480480

481481
function createPeersGeo($peerinfo){
482-
$peersInfo['countryList'] = [];
483-
$peersInfo["peers"] = [];
482+
$peerData['countryList'] = [];
483+
$peerData["peers"] = [];
484484
// Current traffic
485-
$peersInfo["cTraffic"] = 0;
486-
$peersInfo["cTrafficIn"] = 0;
487-
$peersInfo["cTrafficOut"] = 0;
488-
$peersInfo["newPeersCount"] = 0;
485+
$peerData["cTraffic"] = 0;
486+
$peerData["cTrafficIn"] = 0;
487+
$peerData["cTrafficOut"] = 0;
488+
$peerData["newPeersCount"] = 0;
489489
// Not used yet
490-
$peersInfo["hosterCount"] = 0;
491-
$peersInfo["privateCount"] = 0;
490+
$peerData["hosterCount"] = 0;
491+
$peerData["privateCount"] = 0;
492492

493493
$noGeoData = false;
494494

@@ -559,15 +559,15 @@ function createPeersGeo($peerinfo){
559559
// Adds the new peer to the save list
560560
$arrayPeers[$peerObj->id] = array($peerObj->ip, $countryCode, $country, $isp, $hosted, 1);
561561
// Only counted for peers older than 5 minutes
562-
$peersInfo["newPeersCount"]++;
562+
$peerData["newPeersCount"]++;
563563
}elseif($peerObj->age > 5){
564564
// If IP-Api.com call failed we set all data to Unknown and don't store the data
565565
$countryCode = "UN";
566566
$country = "Unknown";
567567
$isp = "Unknown";
568568
$hosted = false;
569569
// Only counted for peers older than 5 minutes
570-
$peersInfo["newPeersCount"]++;
570+
$peerData["newPeersCount"]++;
571571
}else{
572572
// If peer is younger than 5 minutes
573573
$countryCode = "NX";
@@ -590,11 +590,11 @@ function createPeersGeo($peerinfo){
590590
}
591591

592592
// Counts the countries
593-
if(isset($peersInfo['countryList'][$country])){
594-
$peersInfo['countryList'][$country]['count']++;
593+
if(isset($peerData['countryList'][$country])){
594+
$peerData['countryList'][$country]['count']++;
595595
}else{
596-
$peersInfo['countryList'][$country]['code'] = $countryCode;
597-
$peersInfo['countryList'][$country]['count'] = 1;
596+
$peerData['countryList'][$country]['code'] = $countryCode;
597+
$peerData['countryList'][$country]['count'] = 1;
598598
}
599599

600600
// Adds country data to peer object
@@ -603,17 +603,17 @@ function createPeersGeo($peerinfo){
603603
$peerObj->isp = $isp;
604604
$peerObj->hosted = $hosted;
605605
if($hosted){
606-
$peersInfo["hosterCount"]++;
606+
$peerData["hosterCount"]++;
607607
}else{
608-
$peersInfo["privateCount"]++;
608+
$peerData["privateCount"]++;
609609
}
610610
// Adds traffic of each peer to total traffic (in MB)
611-
$peersInfo["cTraffic"] += $peerObj->traffic;
612-
$peersInfo["cTrafficIn"] += $peerObj->trafficIn;
613-
$peersInfo["cTrafficOut"] += $peerObj->trafficOut;
611+
$peerData["cTraffic"] += $peerObj->traffic;
612+
$peerData["cTrafficIn"] += $peerObj->trafficIn;
613+
$peerData["cTrafficOut"] += $peerObj->trafficOut;
614614

615615
// Adds peer to peer array
616-
$peersInfo["peers"][] = $peerObj;
616+
$peerData["peers"][] = $peerObj;
617617

618618
}
619619

@@ -630,7 +630,7 @@ function createPeersGeo($peerinfo){
630630
file_put_contents('data/geodatapeers.inc', $newSerializePeers);
631631
}
632632

633-
return $peersInfo;
633+
return $peerData;
634634
}
635635

636636
function getIpData($ips){

views/main.phtml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@
210210
<h2>Global Peer Distribution</h2>
211211
<ul class="nav navbar-right panel_toolbox">
212212

213-
<li><a class="close-link"><i class="fa fa-close"></i></a>
214-
</li><li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
215-
<li><a><i class="fa fa-question-circle-o" data-toggle="tooltip" data-html="true" data-placement="left" title="BNM will only check the country/isp for peers that are older than 2 minutes."></i></a>
216-
</li>
217-
</li>
213+
<li><a class="close-link"><i class="fa fa-close"></i></a></li>
214+
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
215+
<li><a><i class="fa fa-question-circle-o" data-toggle="tooltip" data-html="true" data-placement="left" title="BNM will only check the country/isp for peers that are older than 5 minutes."></i></a></li>
216+
<?php if(isset($content['api'])) { ?><li><a><i class="fa fa-refresh" data-toggle="tooltip" data-html="true" data-placement="left" title="<?= $content["api"]["callc"] ?> call(s) to API with <?= $content["api"]["ipc"] ?> new ip(s)."></i></a></li><?php }?>
218217

219218
</ul>
220219
<div class="clearfix"></div>

views/peers.phtml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@
5555
<div class="x_title">
5656
<h2>Peers <small>Connected</small></h2>
5757
<ul class="nav navbar-right panel_toolbox">
58-
<li><a class="close-link"><i class="fa fa-close"></i></a>
59-
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
60-
<li><a><i class="fa fa-question-circle-o" data-toggle="tooltip" data-html="true" data-placement="left" title="
61-
Click the 'Rules' button below to run rules."></i></a>
62-
</li>
58+
<li><a class="close-link"><i class="fa fa-close"></i></a></li>
59+
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
60+
<li><a><i class="fa fa-question-circle-o" data-toggle="tooltip" data-html="true" data-placement="left" title="Click the 'Rules' button below to run rules."></i></a></li>
61+
<?php if(isset($content['api'])) { ?><li><a><i class="fa fa-refresh" data-toggle="tooltip" data-html="true" data-placement="left" title="<?= $content["api"]["callc"] ?> call(s) to API with <?= $content["api"]["ipc"] ?> new ip(s)."></i></a></li><?php }?>
6362
</ul>
6463
<div class="clearfix"></div>
6564
</div>
@@ -99,7 +98,7 @@
9998
<td style="padding-right:0px;"> <?= $peer->ping ?></td>
10099
<?php if($content['geo']){ ?> <td style="padding-right:0px;"><?php if($peer->hosted){ ?><i class="fa fa-cloud" title="Hosted"></i><?php } else{ ?><span style="padding-left:18px;"></span><?php } ?> <span title="<?= $peer->isp ?>"><?= substr($peer->isp,0,22) ?></span></td> <?php } ?>
101100
<td style="padding-right:0px;"> <?= $peer->age ?></td>
102-
<td style="padding-right:0px;"><?php if($peer->monitoring){ ?><i class="fa fa-binoculars" title="Monitoring"></i><?php } else{ ?><span style="padding-left:18px;"></span><?php } ?> <span title="<?= $peer->client ?>"><?= substr($peer->client,0,13) ?></span></td>
101+
<td style="padding-right:0px;"><?php if($peer->monitoring){ ?><i class="fa fa-binoculars" title="Monitoring"></i><?php } else{ ?><span style="padding-left:18px;"></span><?php } ?> <span title="<?= $peer->client ?>"><?= substr($peer->client,0,14) ?></span></td>
103102
<td style="padding-right:0px;"> <?= $peer->traffic ?></td>
104103
<td style="padding-right:0px;">
105104
<div class="btn-group pull-left" style="padding:5px 0 3px 0px; margin-bottom:0px">

0 commit comments

Comments
 (0)