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


PHP Stats::lastWinningShareId方法代码示例

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


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

示例1: FindNewGenerations

 function FindNewGenerations($bitcoinController)
 {
     $blockcount = 0;
     $username = '';
     //Get list of last 200 transactions
     $transactions = $bitcoinController->query("listtransactions", "*", "200");
     //Go through all the transactions check if there is 50BTC inside
     $numAccounts = count($transactions);
     for ($i = 0; $i < $numAccounts; $i++) {
         //Check for 50BTC inside only if they are in the generate category
         if ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature") {
             //At this point we may or may not have found a block,
             //Check to see if this account addres is already added to `networkBlocks`
             $accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '" . $transactions[$i]["txid"] . "' ORDER BY blockNumber DESC LIMIT 0,1") or sqlerr(__FILE__, __LINE__);
             $accountExists = mysql_num_rows($accountExistsQ);
             //Insert txid into latest network block
             if (!$accountExists) {
                 //Get last winning block
                 $lastSuccessfullBlockQ = mysql_query("SELECT blockNumber, id, username FROM winning_shares ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
                 $lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
                 $timestamp = $transactions[$i]["time"];
                 $id = $lastSuccessfullBlockR->id;
                 $rpcType = "http";
                 // http or https
                 $rpcUsername = "thisisusername";
                 // username
                 $rpcPassword = "thisissparta";
                 // password
                 $rpcHost = "localhost";
                 $rpcPort = 9000;
                 $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort);
                 $currentBlockNumber = $bitcoinController->getblocknumber();
                 $confirms = $transactions[$i]["confirmations"];
                 $lastBlockNumber = $currentBlockNumber + 1 - $confirms;
                 $stats = new Stats();
                 mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp, accountAddress, confirms) " . "VALUES ('{$lastBlockNumber}', '{$timestamp}', '" . $transactions[$i]["txid"] . "', '" . $transactions[$i]["confirmations"] . "')") or sqlerr(__FILE__, __LINE__);
                 $stats = new Stats();
                 $lastwinningid = $stats->lastWinningShareId();
                 $shareQ = mysql_query("SELECT sum(shares) as total from rounddetails WHERE blockNumber = {$lastBlockNumber}");
                 $shareC = mysql_fetch_object($shareQ);
                 $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > {$lastwinningid}") or sqlerr(__FILE__, __LINE__);
                 while ($winningShareR = mysql_fetch_object($winningShareQ)) {
                     mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ({$lastBlockNumber},'{$winningShareR->username}',{$winningShareR->id})") or sqlerr(__FILE__, __LINE__);
                     removeCache("last_winning_share_id");
                 }
                 //					$q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '".$transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "', shares = ". $shareC->total . " WHERE blockNumber = $lastBlockNumber";
                 $q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '" . $transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "' WHERE blockNumber = {$lastBlockNumber}";
                 echo $q;
                 mysql_query($q) or sqlerr(__FILE__, __LINE__);
                 $username = $lastSuccessfullBlockR->username;
                 $splitUsername = explode(".", $username);
                 $realUsername = $splitUsername[0];
                 $blockcount = $blockcount + 1;
                 $username .= $realUsername . ' ';
             }
         }
     }
 }
开发者ID:bitoncoin,项目名称:Ozcoin,代码行数:58,代码来源:block.php

示例2: Block

ScriptIsRunLocally();
lock("shares");
//Include Block class
include $includedir . "block.php";
$block = new Block();
//Get current block number
$currentBlockNumber = $bitcoinController->getblocknumber();
$lastBlockNumber = $currentBlockNumber - 1;
//Get latest block in database
$latestDbBlock = $block->getLatestDbBlockNumber();
//Do block work if new block
if ($latestDbBlock < $lastBlockNumber) {
    //Insert last block number into networkBlocks
    include $includedir . "stats.php";
    $stats = new Stats();
    $lastwinningid = $stats->lastWinningShareId();
    $block->InsertNetworkBlocks($lastBlockNumber, $lastwinningid);
    //Find new generations
    $block->FindNewGenerations($bitcoinController);
    //Update confirms on unrewarded winning blocks
    $block->UpdateConfirms($bitcoinController);
}
unlock("shares");
//Check for unscored blocks()
if ($block->CheckUnscoredBlocks()) {
    lock("money");
    try {
        //Get Difficulty
        $difficulty = $bitcoinDifficulty;
        if (!$difficulty) {
            echo "no difficulty! exiting\n";
开发者ID:neofutur,项目名称:simplecoin,代码行数:31,代码来源:cronjob.php


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