<?php

//	Enable the spectra functionality
require_once "../lib/spectra_config.php";
//	check for a block number in the command line
if (!isset($argv[1]) or $argv[1] == "") {
    echo "You must provide a block height.\n\n";
    exit;
}
//	Verify that a block exists at this height
$hash = getblockhash((int) $argv[1]);
$block = getblock($hash);
if (!isset($block["hash"])) {
    spectra_log_write(1, "Unable to retrieve block at height " . $argv[1]);
}
//	Process the block with the block parser
spectra_block_load((int) $argv[1]);
//	Some data for the log
spectra_log_write(0, "Inserted block at height " . $argv[1]);
/******************************************************************************
	Developed By Jake Paysnoe - Copyright � 2015 SPEC Development Team
	SPEC Block Explorer is released under the MIT Software License.
	For additional details please read license.txt in this package.
******************************************************************************/
Example #2
0
    //	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;
    //	Load any new blocks available from the node
    while ($start < $top) {
        //	Increment the explorer height to indicate the next desired block
        $start++;
        spectra_log_write(0, "Loading Block: " . $start);
        //	The next block is loaded
        spectra_block_load($start);
        //	Increment the block count
        $count_loaded++;
    }
    //	Log the number of blocks loaded
    spectra_log_write(0, "Loaded " . $count_loaded . " Blocks.");
}
/******************************************************************************
	Rebuild Balances If Indicated
******************************************************************************/
//	Check for the balances flag and rebuild if requested
if (system_flag_get("balance_rebuild") > 0) {
    //	There is another script that will handle this
    include "maint_rebalance.php";
}
/******************************************************************************
Example #3
0
******************************************************************************/
//	Enable the spectra functionality
require_once "../lib/spectra_config.php";
//	Determine the current block height from the node
$targ = getblockcount();
if (is_array($targ)) {
    spectra_log_write(1, "Communication Error: " . print_r($targ["error"], 1));
}
//	Most wallets do not display the genesis (0) block.  The script
//	will begin loading with the first mined block at block 1.
$load = 1;
//	Status for the log
spectra_log_write(0, "Loading " . $GLOBALS["currency"]["name"] . " Block Chain");
spectra_log_write(0, "Node Height: " . $targ);
//	The blocks are loaded from the node.
while ($load <= $targ) {
    //	Each block is written to the log to ensure that any errors
    //	generated can be tracked to the specific block
    spectra_log_write(0, "Loading Block: " . $load);
    //	The current block is parsed into the database
    spectra_block_load($load);
    //	The block counter is updated.
    $load++;
}
//	Completed status for the log
spectra_log_write(0, "No New Block (" . $load . ")");
/******************************************************************************
	Developed By Jake Paysnoe - Copyright � 2015 SPEC Development Team
	SPEC Block Explorer is released under the MIT Software License.
	For additional details please read license.txt in this package.
******************************************************************************/