// Disable the maintenance flag system_flag_set("maintenance", "1"); // Log the communication error and terminate spectra_log_write(1, "Invalid or empty response from node, exiting."); } // If the hashes don't match, the block chain has had a fork/orphan // since the last time the script ran. if ($data_exp["data"]["hash"] != $hash_node) { // A flag is set to rebuild balances at the end of the script system_flag_set("balance_rebuild", 1); // The script will scan back along the chain until it gets a match while ($data_exp["data"]["hash"] != $hash_node) { // If the block hashes do not match, we have a fork. spectra_log_write(0, "Block Data Mismatch at block" . $height_exp); // The invalid block and it's data are removed from the database spectra_orphan_wipe($data_exp["data"]["hash"]); // 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
<?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; } // Retrieve the specified block hash $hash = getblockhash((int) $argv[1]); // Retrieve the block and match it to the requested height $block = getblock($hash); if (!isset($block["hash"])) { echo "Unable to retrieve block " . $hash . "\n"; } if ($block["height"] != $argv[1]) { echo "Block Data Mismatch for block at height " . $argv[1] . "\n"; } // Delete all data related to this block spectra_orphan_wipe($hash); echo "Deleted " . $hash . "\n\n"; // Some data for the log // spectra_log_write (1, $forksize." Invalid Blocks Inserted"); /****************************************************************************** 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. ******************************************************************************/