当前位置: 首页>>代码示例>>PHP>>正文


PHP jsonRPCClient::getblock方法代码示例

本文整理汇总了PHP中jsonRPCClient::getblock方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::getblock方法的具体用法?PHP jsonRPCClient::getblock怎么用?PHP jsonRPCClient::getblock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonRPCClient的用法示例。


在下文中一共展示了jsonRPCClient::getblock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_block_info

function get_block_info($block){
	require_once('/var/www/midas/root/private/class/jsonRPCClient.php');
	$darkcoin = new jsonRPCClient('http://xxxx:yyyy@127.0.0.1:9998/');
	$hash_block = $darkcoin->getblockhash(intval($block));
	
	$info_block = $darkcoin->getblock($hash_block);
	$tx = $info_block["tx"][0];
	$diff = round($info_block["difficulty"]);
	$last_block = $block_id = $info_block["height"];
	$block_time = $info_block["time"];
	return $info_block;
}
开发者ID:Karasur,项目名称:dashpay.org.ru,代码行数:12,代码来源:func.php

示例2: mysqli

$rpchost = 'localhost';
$rpcuser = 'protosharesrpc';
$rpcpass = 'superdupersecretphrase';
$rpcport = '3838';
////////////////////////////////////////////////////////////////////////////////
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $database);
if ($mysqli->connect_errno) {
    throw new Exception("database connection error");
}
$r = $mysqli->query("select max(block_num) from outputs", MYSQLI_USE_RESULT);
$w = $r->fetch_assoc();
$blocknum = $w["max(block_num)"] + 0;
$r->close();
$r = $mysqli->query("select sum(balance) from outputs", MYSQLI_USE_RESULT);
$w = $r->fetch_assoc();
$moneysupply = $w["sum(balance)"] + 0;
$r->close();
$pts = new jsonRPCClient("http://" . $rpcuser . ":" . $rpcpass . "@" . $rpchost . ":" . $rpcport);
$blockhash = $pts->getblockhash($blocknum);
$blockinfo = $pts->getblock($blockhash);
$blocktime = $blockinfo['time'];
echo "{\"blocknum\":" . $blocknum . ",\"blocktime\":" . $blocktime . ",\"moneysupply\":" . $moneysupply . ",\"balances\":\n";
echo "    {\n";
$r = $mysqli->query("select * from outputs group by address order by balance desc", MYSQLI_USE_RESULT);
while ($w = $r->fetch_assoc()) {
    echo "        \"" . $w['address'] . "\":" . $w['balance'] . ",\n";
}
echo "    }\n";
echo "}";
$r->close();
////////////////////////////////////////////////////////////////////////////////
开发者ID:amtjre,项目名称:pts-unspent,代码行数:31,代码来源:update-jsonapi.php

示例3: foreach

             if (is_array($unspents) && count($unspents) > 0) {
                 $balance = 0;
                 foreach (array_reverse($unspents) as $tx) {
                     $balance = $balance + intval($tx['amount'] * 100000000);
                 }
                 $obj['balance'] = $balance;
             }
         }
     }
 } else {
     if ($call == 'block') {
         $obj = ["blockchain" => $blockchain, "height" => "N/A", "hash" => "N/A", "prev" => "N/A", "next" => "N/A", "tx_count" => 0, "time" => "N/A"];
         if (isset($_GET['id']) && $_GET['id']) {
             $height = intval($_GET['id']);
             $block_hash = $bitcoind->getblockhash($height);
             $block = $bitcoind->getblock($block_hash);
             $obj['raw'] = $block;
             if ($block_hash) {
                 $obj['height'] = $height;
                 $obj['hash'] = $block_hash;
             }
             if ($block) {
                 if (isset($block['previousblockhash']) && $block['previousblockhash']) {
                     $obj['prev'] = $block['previousblockhash'];
                 }
                 if (isset($block['nextblockhash']) && $block['nextblockhash']) {
                     $obj['next'] = $block['nextblockhash'];
                 }
                 if (isset($block['tx']) && is_array($block['tx'])) {
                     $obj['tx_count'] = count($block['tx']);
                 }
开发者ID:blockstrap,项目名称:blockstrap.github.io,代码行数:31,代码来源:rpc.php

示例4: mysqli

$rpcport = '3838';
////////////////////////////////////////////////////////////////////////////////
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $database);
if ($mysqli->connect_errno) {
    throw new Exception("database connection error");
}
$r = $mysqli->query("select max(block_num) from outputs", MYSQLI_USE_RESULT);
$w = $r->fetch_assoc();
$last_block_in_db = $w["max(block_num)"] + 0;
$r->close();
$pts = new jsonRPCClient("http://" . $rpcuser . ":" . $rpcpass . "@" . $rpchost . ":" . $rpcport);
$blocknum = $pts->getblockcount();
if ($last_block_in_db < $blocknum) {
    for ($i = $last_block_in_db + 1; $i <= $blocknum; $i++) {
        echo "block " . $i . "\n";
        $block = $pts->getblock($pts->getblockhash($i));
        foreach ($block["tx"] as $txid) {
            $tx = $pts->decoderawtransaction($pts->getrawtransaction($txid));
            foreach ($tx["vin"] as $tx_in) {
                if (!array_key_exists("coinbase", $tx_in)) {
                    $mysqli->query("delete from outputs where transaction_hash='" . $tx_in["txid"] . "' and sequence=" . $tx_in["vout"] . ";");
                }
            }
            foreach ($tx["vout"] as $tx_out) {
                $scripttype = $tx_out["scriptPubKey"]["type"];
                switch ($scripttype) {
                    case "pubkeyhash":
                    case "pubkey":
                    case "scripthash":
                        $mysqli->query("insert into outputs (block_num, block_hash, transaction_hash, sequence, address, balance) values (" . $i . ", '" . $block["hash"] . "', '" . $txid . "', " . $tx_out["n"] . ", '" . $tx_out["scriptPubKey"]["addresses"][0] . "', " . $tx_out["value"] . ")");
                        break;
开发者ID:amtjre,项目名称:pts-unspent,代码行数:31,代码来源:update-database.php

示例5: copyBlockToDB

 /**
  * @param $blockID - Block ID to process
  * @return mixed
  * @throws \RedBeanPHP\RedException
  */
 private static function copyBlockToDB($blockID)
 {
     $wallet = new jsonRPCClient(HOTWALLET, true);
     $getBlockHash = $wallet->getblockhash($blockID);
     $getBlock = $wallet->getblock($getBlockHash);
     //$return['getBlockHash'] = $getBlockHash;
     //$return['getBlock']     = $getBlock;
     $findOne = R::findOne('blocks', 'height = ?', [$blockID]);
     if (!$findOne) {
         $dispense = R::dispense('blocks');
         foreach ($getBlock as $key => $value) {
             if ($key == "tx") {
                 $dispense->{$key} = json_encode($value);
                 $processTX = self::processTransactions($value);
                 $dispense->totalvalue = $processTX['totalValue'];
                 $dispense->transactioncount = $processTX['transactionCount'];
             } else {
                 $dispense->{$key} = $value;
             }
         }
         R::store($dispense);
     }
     //$return['processTX'] = $processTX;
     $return['data'] = "Processed";
     return $return;
 }
开发者ID:newmight2015,项目名称:BlockExplorer,代码行数:31,代码来源:run.php


注:本文中的jsonRPCClient::getblock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。