forked from baumann-at/MultiChain-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmc-info.php
More file actions
52 lines (42 loc) · 1.38 KB
/
mc-info.php
File metadata and controls
52 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Functions to collect and build information about a server running one or
* more Multichain nodes, based on the configuration in config.php
*
* @author Chris Baumann <c.baumann@baumann.at>
* @copyright 2020 baumann.at - concepts & solutions
* @version mc-info v0.1 - 11.1.2020
*/
require_once 'functions.php';
$mcInfoConfig = new stdClass;
$configs = read_config();
$nodes = array();
foreach ($configs as $config) {
$name = $config['name'];
$nodes[$name] = getChainInfo($config);
}
$mcInfo = new stdClass;
$mcInfo->serverName = $mcInfoConfig->serverName;
$mcInfo->serverOwner = $mcInfoConfig->serverOwner;
$mcInfo->version = 'mc-info v0.1';
$mcInfo->extIPconfigured = $mcInfoConfig->extIPconfigured;
$res = new stdClass;
$res->mcInfo = $mcInfo;
$res->nodes = $nodes;
header("Content-Type: application/json; charset=UTF-8");
echo (json_encode($res));
function getChainInfo($config) {
$res = array();
set_multichain_chain($config);
$getInfo = multichain('getinfo');
if (isset($getInfo['error']['code'])) {
$res['status'] = 'Error: Blockchain API returns: ' . $getInfo['error']['code'];
return ($res);
}
$res['status'] = 'OK 200';
$res['getinfo'] = $getInfo['result'];
$res['getconnectioncount'] = multichain('getconnectioncount') ['result'];
$res['getpeerinfo'] = multichain('getpeerinfo') ['result'];
return ($res);
}
?>