function getblock($blockhash, $verbose = FALSE)
{
    $request_array["method"] = "getblock";
    $request_array["params"][0] = $blockhash;
    //	For dealing with multiple chains SPECTRA requires an
    //	override on the "verbose" parameter
    if (system_flag_get("block_req_verbose") == 0) {
        $request_array["params"][1] = FALSE;
    } else {
        $request_array["params"][1] = TRUE;
    }
    return daemon_fetch($request_array);
}
function spectra_money_top1000()
{
    if (system_flag_get("balance_rebuild") > 0) {
        $balance_calc["total"] = "Re-Balancing";
        $balance_calc["percent"] = "0.00";
        return $balance_calc;
    }
    $accounts = mysqli_getset($GLOBALS["tables"]["ledger"], "1 ORDER BY `balance` DESC LIMIT 1000 OFFSET 100");
    if ($accounts["success"] < 1 || $accounts["data"] == "") {
        $balance_calc["total"] = "Unavailable";
        $balance_calc["percent"] = "0.00";
        return $balance_calc;
    }
    //	Initialize Calculation Result
    $sum_balances = 0;
    foreach ($accounts["data"] as $account) {
        $sum_balances = bcadd($sum_balances, $account["balance"], 8);
    }
    $calc_perc = bcdiv($sum_balances, spectra_money_supply(), 8);
    $balance_calc["total"] = $sum_balances;
    $balance_calc["percent"] = $calc_perc * 100;
    return $balance_calc;
}
示例#3
0
        //	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";
}
/******************************************************************************
	Reset Maintenance Flags
******************************************************************************/
//	Reset the maintenance mode flag
system_flag_set("maintenance", 0);
//	Log the time of completion
spectra_log_write(0, "Script maint_crontab.php complete.");
/******************************************************************************
	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.
******************************************************************************/
示例#4
0
{
    //	Build the response array
    $response["status"] = $status;
    $response["message"] = $message;
    $response["data"] = $data;
    //	Apply the expected JSON format
    echo json_encode($response);
    //	Update the rate flag timer
    system_flag_set(hash_hmac("sha256", $_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"]), time());
    exit;
}
/******************************************************************************
	Connection and Request Error Handling
******************************************************************************/
//	If this IP has passed the rate limit the request is rejected
$last_req = system_flag_get(hash_hmac("sha256", $_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"]));
if (time() < floor($last_req + $GLOBALS["api_rate_limit"])) {
    spectra_api_response("", 0, "Request Rate Limit Exceeded");
}
//	If no method is specified the API returns an error
if (!isset($_REQUEST["method"]) || $_REQUEST["method"] == "") {
    spectra_api_response("", 0, "Method Is Required");
}
/******************************************************************************
	Ticker API 
******************************************************************************/
if ($_REQUEST["method"] == "ticker") {
    //	The ticker is requested from each enabled exchange
    foreach ($GLOBALS["markets"] as $market) {
        //	Format the request for this exchange
        $function_name = "spectra_ticker_" . $market["exch_id"];