예제 #1
0
         }
     }
 }
 $sql = "SELECT MNTestNet, COUNT(*) MNActive FROM " . "(SELECT cim.MasternodeOutputHash MasternodeOutputHash, cim.MasternodeOutputIndex MasternodeOutputIndex, cim.MasternodeTestNet MNTestNet, COUNT(1) ActiveCount FROM " . "cmd_info_masternode2_list ciml, cmd_info_masternode2 cim, (SELECT NodeTestNet, MAX(NodeProtocol) Protocol FROM " . "cmd_nodes cn, cmd_nodes_status cns WHERE cn.NodeId = cns.NodeId GROUP BY NodeTestnet) maxprot WHERE cim.MasternodeOutputHash = ciml.MasternodeOutputHash " . "AND ciml.MasternodeOutputIndex = cim.MasternodeOutputIndex AND ciml.MasternodeTestNet = cim.MasternodeTestNet AND (MasternodeStatus = 'active' OR MasternodeStatus = 'current') " . "AND cim.MasternodeProtocol = maxprot.Protocol AND ciml.MasternodeTestNet = maxprot.NodeTestNet " . "GROUP BY cim.MasternodeOutputHash, cim.MasternodeOutputIndex, cim.MasternodeTestNet) mnactive " . "WHERE ActiveCount > 0 GROUP BY MNTestNet";
 $sqlstats2 = array();
 $activemncount = 0;
 $activemncountarr[0] = 0;
 $activemncountarr[1] = 0;
 $uniquemnips = 0;
 drkmn_masternodes_count($mysqli, 0, $activemncount, $uniquemnips);
 $sqlstats2[] = sprintf("('%s','%s',%d,'dashninja')", 'mnactive', $activemncount, time());
 $sqlstats2[] = sprintf("('%s','%s',%d,'dashninja')", 'mnuniqiptest', $uniquemnips, time());
 $activemncountarr[0] = $activemncount;
 $activemncount = 0;
 $uniquemnips = 0;
 drkmn_masternodes_count($mysqli, 1, $activemncount, $uniquemnips);
 $sqlstats2[] = sprintf("('%s','%s',%d,'dashninja')", 'mnactivetest', $activemncount, time());
 $sqlstats2[] = sprintf("('%s','%s',%d,'dashninja')", 'mnuniqiptest', $uniquemnips, time());
 $activemncountarr[1] = $activemncount;
 $sql = "SELECT StatKey, StatValue FROM cmd_stats_values WHERE StatKey = 'usdbtc' OR StatKey = 'btcdrk' OR StatKey = 'eurobtc'";
 if ($result = $mysqli->query($sql)) {
     while ($row = $result->fetch_assoc()) {
         $tmp[$row['StatKey']] = floatval($row['StatValue']);
     }
     $result->free();
     $pricebtc = $tmp['btcdrk'];
     $priceeur = $pricebtc * $tmp['eurobtc'];
     $priceusd = $pricebtc * $tmp['usdbtc'];
 }
 foreach ($testnetval as $testnet) {
     $sqlstats[] = sprintf("(%d,NOW(),%d,%d,%01.9f,%01.9f,%01.9f)", $testnet, $activemncount[$testnet], $networkhashps[$testnet], $pricebtc, $priceusd, $priceeur);
예제 #2
0
     while ($row = $result->fetch_assoc()) {
         $supplyinfo[$row['Protocol']] = array("TotalMNValue" => $row['TotalMNValue'], "TotalSupply" => $row['TotalSupply'], "TotalMNPayed" => $row['TotalMNPayed'], "TotalBlocks" => $row['TotalBlocks'], "RatioPayed" => 0);
         $totalsupplyinfo['TotalMNValue'] += $row['TotalMNValue'];
         $totalsupplyinfo['TotalSupply'] += $row['TotalSupply'];
         $totalsupplyinfo['TotalMNPayed'] += $row['TotalMNPayed'];
         $totalsupplyinfo['TotalBlocks'] += $row['TotalBlocks'];
     }
     $totalsupplyinfo['RatioPayed'] = $totalsupplyinfo['TotalMNPayed'] / $totalsupplyinfo['TotalBlocks'];
 } else {
     $response->setStatusCode(503, "Service Unavailable");
     $response->setJsonContent(array('status' => 'ERROR', 'messages' => array($mysqli->errno . ': ' . $mysqli->error)));
     return $response;
 }
 $totalmninfo = 0;
 $totaluniqueips = 0;
 $mninfo = drkmn_masternodes_count($mysqli, $testnet, $totalmninfo, $totaluniqueips);
 if ($mninfo === false) {
     $response->setStatusCode(503, "Service Unavailable");
     $response->setJsonContent(array('status' => 'ERROR', 'messages' => array($mysqli->errno . ': ' . $mysqli->error)));
     return $response;
 }
 // Compute the results
 $finalinfo = array();
 foreach ($supplyinfo as $protocol => $info) {
     $info['RatioPayed'] = $info['TotalMNPayed'] / $totalsupplyinfo['TotalBlocks'];
     $finalinfo[$protocol] = $info;
     if (array_key_exists($protocol, $mninfo)) {
         $finalinfo[$protocol]['ActiveMasternodesCount'] = $mninfo[$protocol]['ActiveMasternodesCount'];
         $finalinfo[$protocol]['ActiveMasternodesUniqueIPs'] = $mninfo[$protocol]['ActiveMasternodesCount'];
         $finalinfo[$protocol]['MasternodeExpectedPayment'] = $info['TotalMNValue'] / $finalinfo[$protocol]['ActiveMasternodesCount'];
     } else {