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


PHP foundation_cycle函数代码示例

本文整理汇总了PHP中foundation_cycle函数的典型用法代码示例。如果您正苦于以下问题:PHP foundation_cycle函数的具体用法?PHP foundation_cycle怎么用?PHP foundation_cycle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: gen_simple_poll_test

function gen_simple_poll_test($ip_address, $domain, $subfolder, $port_number)
{
    $simple_poll_fail = FALSE;
    // Reset Variable
    TKRandom::seed(transaction_cycle(0, TRUE));
    // Grab random Transaction Foundation Hash
    $rand_block = TKRandom::num(0, foundation_cycle(0, TRUE) - 5);
    // Range from Start to Last 5 Foundation Hash
    $random_foundation_hash = mysql_result(mysql_query("SELECT hash FROM `transaction_foundation` WHERE `block` = {$rand_block} LIMIT 1"), 0, 0);
    // Grab random Transaction Hash
    $rand_block2 = TKRandom::num(transaction_cycle(0 - transaction_cycle(0, TRUE), TRUE), transaction_cycle(-1000, TRUE));
    // Range from Start to Last 1000 Transaction Hash
    $rand_block2 = transaction_cycle(0 - $rand_block2);
    $random_transaction_hash = mysql_result(mysql_query("SELECT hash FROM `transaction_history` WHERE `timestamp` = {$rand_block2} LIMIT 1"), 0, 0);
    $rand_block2 = ($rand_block2 - TRANSACTION_EPOCH - 300) / 300;
    if (empty($random_foundation_hash) == FALSE) {
        $poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 64, "foundation.php?action=block_hash&block_number={$rand_block}");
        // Is it valid?
        if (empty($poll_peer) == TRUE) {
            // No response?
            $simple_poll_fail = TRUE;
        } else {
            // Is it valid?
            if ($poll_peer == $random_foundation_hash) {
                // Got a good response from an active Timekoin server
                $simple_poll_fail = FALSE;
            } else {
                // Wrong Response?
                $simple_poll_fail = TRUE;
            }
        }
    }
    if (empty($random_transaction_hash) == FALSE) {
        $poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 64, "transclerk.php?action=block_hash&block_number={$rand_block2}");
        // Is it valid?
        if (empty($poll_peer) == TRUE) {
            //No response?
            $simple_poll_fail = TRUE;
        } else {
            // Is it valid?
            if ($poll_peer == $random_transaction_hash) {
                //Got a good response from an active Timekoin server
                $simple_poll_fail = FALSE;
            } else {
                //Wrong Response?
                $simple_poll_fail = TRUE;
            }
        }
    }
    return $simple_poll_fail;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:51,代码来源:function.php

示例2: mysql_result

     //***********************************************************************************
     //***********************************************************************************
 } else {
     // Entire Transaction History in sync, reset block check start to 0
     $block_check_start = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'block_check_start' LIMIT 1"), 0, "field_data");
     if ($block_check_start > 0) {
         mysql_query("UPDATE `main_loop_status` SET `field_data` = '0' WHERE `main_loop_status`.`field_name` = 'block_check_start' LIMIT 1");
         mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'block_check_back' LIMIT 1");
         // Reset Performance Data
         mysql_query("UPDATE `main_loop_status` SET `field_data` = '10' WHERE `main_loop_status`.`field_name` = 'peer_transaction_performance' LIMIT 1");
         mysql_query("UPDATE `main_loop_status` SET `field_data` = '10' WHERE `main_loop_status`.`field_name` = 'peer_transaction_start_blocks' LIMIT 1");
     }
     if (rand(1, 4) == 2) {
         // Poll a random block from a random peer for random accuracy :)
         // Within the range of the current foundation block to now
         $current_foundation_block = foundation_cycle(0, TRUE) * 500;
         $random_block = rand($current_foundation_block, transaction_cycle(-1, TRUE));
         $sql = perm_peer_mode();
         $sql_result = mysql_query($sql);
         $sql_num_results = mysql_num_rows($sql_result);
         if ($sql_num_results > 0) {
             $sql_row = mysql_fetch_array($sql_result);
             $ip_address = $sql_row["IP_Address"];
             $domain = $sql_row["domain"];
             $subfolder = $sql_row["subfolder"];
             $port_number = $sql_row["port_number"];
             $poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 65, "transclerk.php?action=block_hash&block_number={$random_block}");
             if (empty($poll_peer) == TRUE) {
                 // Add failure points to the peer in case further issues
                 modify_peer_grade($ip_address, $domain, $subfolder, $port_number, 4);
             }
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:transclerk.php

示例3: tools_bar

function tools_bar()
{
    $default_walk = foundation_cycle(0, TRUE) * 500;
    $default_check = transaction_cycle(0, TRUE) - 10;
    $default_current = transaction_cycle(0, TRUE);
    return '<table cellspacing="10" border="0"><tr><td><FORM ACTION="index.php?menu=tools&action=walk_history" METHOD="post"><input type="submit" value="History Walk"/></td>
		<td>Block#<input type="text" size="7" name="walk_history" value="' . $default_walk . '" /></td></FORM><td>|</br>|</td>
		<td><FORM ACTION="index.php?menu=tools&action=check_tables" METHOD="post"><input type="submit" value="Check DB"/></td></FORM></td><td>|</br>|</td>
		<td><FORM ACTION="index.php?menu=tools&action=optimize_tables" METHOD="post"><input type="submit" value="Optimize DB"/></td></FORM></td><td>|</br>|</td>
		<td><FORM ACTION="index.php?menu=tools&action=repair_tables" METHOD="post"><input type="submit" value="Repair DB"/></td></FORM>
		</tr></table><hr></hr>
		<table cellspacing="10" border="0"><tr><td><FORM ACTION="index.php?menu=tools&action=schedule_check" METHOD="post"><input type="submit" value="Schedule Check"/></td>
		<td>Block#<input type="text" size="7" name="schedule_check" value="' . $default_check . '" /></td></FORM><td>|</br>|</td>
		<td><FORM ACTION="index.php?menu=tools&action=repair" METHOD="post"><input type="submit" value="Repair"/></td>
		<td>From Block#<input type="text" size="7" name="repair_from" value="' . $default_check . '" /></td>
		</FORM></tr></table>';
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:17,代码来源:templates.php

示例4: write_log

                 write_log("Updating Balance Index From Transaction Queue", "BA");
                 check_crypt_balance($sql_row["public_key"]);
                 $created = TRUE;
                 break;
             }
         }
     }
     if ($created == FALSE) {
         // 1000 Transaction Cycles Back in time to index
         $time_back = time() - 300000;
         $sql = "SELECT public_key_to FROM `transaction_history` WHERE `timestamp` > {$time_back} GROUP BY `public_key_to` ORDER BY RAND() LIMIT 1";
         $sql_result = mysql_query($sql);
         $sql_row = mysql_fetch_array($sql_result);
         $public_key_hash = hash('md5', $sql_row["public_key_to"]);
         // Run a balance index if one does not already exist
         $balance_index = mysql_result(mysql_query("SELECT public_key_hash FROM `balance_index` WHERE `public_key_hash` = '{$public_key_from}' AND `block` = '" . foundation_cycle(-1, TRUE) . "' LIMIT 1"), 0, 0);
         if (empty($balance_index) == TRUE) {
             // No index balance, go ahead and create one
             write_log("Updating Balance Index From Transaction History", "BA");
             check_crypt_balance($sql_row["public_key_to"]);
         }
     }
 }
 //***********************************************************************************
 //***********************************************************************************
 $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, "field_data");
 // Check script status
 if ($loop_active == 3) {
     // Time to exit
     mysql_query("UPDATE `main_loop_status` SET `field_data` = '0' WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active' LIMIT 1");
     exit;
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:balance.php

示例5: check_crypt_balance

function check_crypt_balance($public_key)
{
    if (empty($public_key) == TRUE) {
        return 0;
    }
    // Do we already have an index to reference for faster access?
    $public_key_hash = hash('md5', $public_key);
    $current_generation_block = transaction_cycle(0, TRUE);
    $current_foundation_block = foundation_cycle(0, TRUE);
    // Check to make sure enough lead time exist in advance to building
    // another balance index. (60 blocks) or 5 hours
    if ($current_generation_block - $current_foundation_block * 500 > 60) {
        // -1 Foundation Blocks (Standard)
        $previous_foundation_block = foundation_cycle(-1, TRUE);
    } else {
        // -2 Foundation Blocks - Buffers 5 hours after the newest foundation block
        $previous_foundation_block = foundation_cycle(-2, TRUE);
    }
    $sql = "SELECT * FROM `balance_index` WHERE `block` = {$previous_foundation_block} AND `public_key_hash` = '{$public_key_hash}' LIMIT 1";
    $sql_result = mysql_query($sql);
    $sql_row = mysql_fetch_array($sql_result);
    if (empty($sql_row["block"]) == TRUE) {
        // No index exist yet, so after the balance check is complete, record the result
        // for later use
        $crypto_balance = 0;
        // Create time range
        $end_time_range = $previous_foundation_block * 500;
        $index_balance1 = check_crypt_balance_range($public_key, 0, $end_time_range);
        // Check balance between the last block and now
        $start_time_range = $end_time_range;
        $end_time_range = transaction_cycle(0, TRUE);
        $index_balance2 = check_crypt_balance_range($public_key, $start_time_range, $end_time_range);
        // Store index in database for future access
        $sql = "INSERT INTO `balance_index` (`block` ,`public_key_hash` ,`balance`)\n\t\tVALUES ('{$previous_foundation_block}', '{$public_key_hash}', '{$index_balance1}')";
        mysql_query($sql);
        return $index_balance1 + $index_balance2;
    } else {
        $crypto_balance = $sql_row["balance"];
        // Check balance between the last block and now
        $start_time_range = $previous_foundation_block * 500;
        $end_time_range = transaction_cycle(0, TRUE);
        $index_balance = check_crypt_balance_range($public_key, $start_time_range, $end_time_range);
        return $crypto_balance + $index_balance;
    }
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:45,代码来源:function.php

示例6: mysql_query

         if ($new_peer_difference <= 0) {
             // Enough new peers saved, break out of for loop early
             break;
         }
     }
     // End For loop check
 }
 // End New Peers vs Max New Peers check
 //***********************************************************************************
 //***********************************************************************************
 // Send a heartbeat to all active peers in our list to make sure they are still online
 $sql = "SELECT * FROM `active_peer_list`";
 $sql_result = mysql_query($sql);
 $sql_num_results = mysql_num_rows($sql_result);
 // Grab random Transaction Foundation Hash
 $rand_block = rand(0, foundation_cycle(0, TRUE) - 5);
 // Range from Start to Last 5 Foundation Hash
 $random_foundation_hash = mysql_result(mysql_query("SELECT hash FROM `transaction_foundation` WHERE `block` = {$rand_block} LIMIT 1"), 0, 0);
 // Grab random Transaction Hash
 $rand_block2 = rand(transaction_cycle(0 - transaction_cycle(0, TRUE), TRUE), transaction_cycle(-1000, TRUE));
 // Range from Start to Last 1000 Transaction Hash
 $rand_block2 = transaction_cycle(0 - $rand_block2);
 $random_transaction_hash = mysql_result(mysql_query("SELECT hash FROM `transaction_history` WHERE `timestamp` = {$rand_block2} LIMIT 1"), 0, 0);
 $rand_block2 = ($rand_block2 - TRANSACTION_EPOCH - 300) / 300;
 for ($i = 0; $i < $sql_num_results; $i++) {
     $sql_row = mysql_fetch_array($sql_result);
     if (rand(1, 2) == 2) {
         $ip_address = $sql_row["IP_Address"];
         $domain = $sql_row["domain"];
         $subfolder = $sql_row["subfolder"];
         $port_number = $sql_row["port_number"];
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:peerlist.php

示例7: transaction_cycle

 $next_transaction_cycle = transaction_cycle(1);
 $foundation_status = intval(mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'foundation_heartbeat_active' LIMIT 1"), 0, 0));
 // Can we work on the key balances in the database?
 // Not allowed 120 seconds before and 40 seconds after transaction cycle.
 // Don't run if the Foundation Manager is busy (idle = 2)
 if ($next_transaction_cycle - time() > 120 && time() - $current_transaction_cycle > 40 && $foundation_status == 2) {
     $current_transaction_block = transaction_cycle(0, TRUE);
     $current_foundation_block = foundation_cycle(0, TRUE);
     // Check to make sure enough lead time exist in advance to building
     // another balance index. (60 cycles) or 5 hours
     if ($current_transaction_block - $current_foundation_block * 500 > 60) {
         // -1 Foundation Blocks (Standard)
         $cache_block = foundation_cycle(-1, TRUE);
     } else {
         // -2 Foundation Blocks - Buffers 5 hours after the newest foundation block
         $cache_block = foundation_cycle(-2, TRUE);
     }
     // Build self balance index first
     $public_key_hash = hash('md5', my_public_key());
     $balance_index = mysql_result(mysql_query("SELECT block FROM `balance_index` WHERE `public_key_hash` = '{$public_key_hash}' AND `block` = {$cache_block} LIMIT 1"), 0, 0);
     if ($balance_index === FALSE) {
         // Create self first :)
         check_crypt_balance(my_public_key());
     }
     // Build Balance Index for Transactions about to be Processed in the Queue
     $sql = "SELECT public_key FROM `transaction_queue` WHERE `attribute` = 'T'";
     $sql_result = mysql_query($sql);
     $sql_num_results = mysql_num_rows($sql_result);
     $queue_index_created = FALSE;
     if ($sql_num_results > 0) {
         for ($i = 0; $i < $sql_num_results; $i++) {
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:balance.php


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