function spectra_block_browser($per_page)
{
    //	The values required to paginate are calculated
    $page = spectra_page_describe("block_page", spectra_block_height(), 20);
    //	The list of blocks for this page is retrieved
    $block_list = mysqli_getset($GLOBALS["tables"]["block"], "TRUE ORDER BY `height` DESC LIMIT " . $page["per"] . " OFFSET " . $page["offset"]);
    //	Display header for the block browser
    echo "\t<h1> " . $GLOBALS["currency"]["name"] . " Block Explorer </h1> \n\n";
    //	Wrapper for the block browser
    echo "\t<div class=\"panel_wide\"> \n\n";
    //	Browsing Controls
    spectra_page_control($page);
    //	Wrapper for the block list
    echo "\t\t<div class=\"block_browse\"> \n\n";
    //	Header row for the block list
    echo "\t\t\t<div class=\"blocklist_head\"> \n\n";
    echo "\t\t\t\t<div class=\"blocklist_head_height\"> \n";
    echo "\t\t\t\t\tHeight \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_flag\"> \n";
    echo "\t\t\t\t\tType \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_age\"> \n";
    echo "\t\t\t\t\tAge \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_tx\"> \n";
    echo "\t\t\t\t\tTX \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_value\"> \n";
    echo "\t\t\t\t\t" . $GLOBALS["currency"]["code"] . " Value \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_diff\"> \n";
    echo "\t\t\t\t\tDifficulty \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t\t<div class=\"blocklist_head_size\"> \n";
    echo "\t\t\t\t\tSize (Bytes) \n";
    echo "\t\t\t\t</div> \n";
    echo "\t\t\t</div> \n\n";
    //	Render the block list
    foreach ($block_list["data"] as $block_data) {
        //	Enable alternating row colors
        if (isset($blktype) && $blktype == "even") {
            //	Odd row type
            echo "\t\t\t<div class=\"blocklist_block_odd\"> \n\n";
            //	Reset the row type for the next row
            $blktype = "odd";
        } else {
            //	Odd row type
            echo "\t\t\t<div class=\"blocklist_block_even\"> \n\n";
            //	Reset the row type for the next row
            $blktype = "even";
        }
        echo "\t\t\t\t<div class=\"blocklist_data_height\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?height=" . $block_data["height"] . "\" title=\"View Block " . $block_data["height"] . "\"> \n";
        echo "\t\t\t\t\t\t" . $block_data["height"] . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_flag\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?height=" . $block_data["height"] . "\" title=\"View Block " . $block_data["height"] . "\"> \n";
        if (strcasecmp(substr($block_data["flags"], 0, 14), "proof-of-stake") == 0) {
            echo "\t\t\t\t\t\tPOS \n";
        } else {
            echo "\t\t\t\t\t\tPOW \n";
        }
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_age\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?hash=" . $block_data["hash"] . "\" title=\"View Block " . $block_data["hash"] . "\"> \n";
        echo "\t\t\t\t\t\t" . floor((time() - $block_data["time"]) / 60) . " Mins\n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_tx\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?hash=" . $block_data["hash"] . "\" title=\"View Block " . $block_data["hash"] . "\"> \n";
        echo "\t\t\t\t\t\t" . spectra_block_txcount($block_data["hash"]) . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_value\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?hash=" . $block_data["hash"] . "\" title=\"View Block " . $block_data["hash"] . "\"> \n";
        echo "\t\t\t\t\t\t" . $block_data["val_out"] . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_diff\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?hash=" . $block_data["hash"] . "\" title=\"View Block " . $block_data["hash"] . "\"> \n";
        echo "\t\t\t\t\t\t" . $block_data["difficulty"] . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t\t<div class=\"blocklist_data_size\"> \n";
        echo "\t\t\t\t\t<a href=\"block.php?hash=" . $block_data["hash"] . "\" title=\"View Block " . $block_data["hash"] . "\"> \n";
        echo "\t\t\t\t\t\t" . $block_data["size"] . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n";
        echo "\t\t\t</div> \n\n";
    }
    //	Close the block list wrapper
    echo "\t\t</div> \n\n";
    //	Browsing Controls
    spectra_page_control($page);
    //	Close the block browser wrapper
    echo "\t</div> \n\n";
}
Example #2
0
        //	The explorer block height is decremented
        $height_exp = $height_exp - 1;
        //	The next block is retrieved from the explorer
        $data_exp = mysqli_getrow($GLOBALS["tables"]["block"], "`height` = '" . $height_exp . "'");
        //	The next hash is retrieved from the node
        $hash_node = getblockhash($height_exp);
        //	The while loop will perform the comparison against the new values
    }
    //	The block height of the match found is written to the log
    spectra_log_write(0, "Found sync at block " . $height_exp);
}
/******************************************************************************
	Load New Blocks
******************************************************************************/
//	Block heights are reloaded in case of a resync
$start = spectra_block_height();
$top = getblockcount();
//	If there is not a new block, end the checks
if ($start >= $top) {
    //	Make a note to the maintenance log
    spectra_log_write(0, "No new block, loading complete.");
} else {
    //	Log the new block height
    spectra_log_write(0, "Explorer Block: " . $start . " - Node Block: " . $top);
    //	Get the data for the prior block from the node
    $hash_back = getblockhash((int) $start);
    $data_node = getblock($hash_back);
    //	Update the prior block record
    $result = mysqli_setfield($GLOBALS["tables"]["block"], "nextblockhash", $data_node["nextblockhash"], "`hash` = '" . $data_node["hash"] . "'");
    //	Initialize a block counter for logging
    $count_loaded = 0;