Add apiDoc comments for the sanity endpoint
This commit is contained in:
33
api.php
33
api.php
@@ -423,8 +423,8 @@ if ($q == "getAddress") {
|
|||||||
api_err("Invalid destination alias");
|
api_err("Invalid destination alias");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$public_key = san($data['public_key']);
|
$public_key = san($data['public_key']);
|
||||||
if (!$acc->valid_key($public_key)) {
|
if (!$acc->valid_key($public_key)) {
|
||||||
@@ -454,7 +454,7 @@ if ($q == "getAddress") {
|
|||||||
if ($date > time() + 86400) {
|
if ($date > time() + 86400) {
|
||||||
api_err("Invalid Date");
|
api_err("Invalid Date");
|
||||||
}
|
}
|
||||||
|
|
||||||
$message=$data['message'];
|
$message=$data['message'];
|
||||||
if (strlen($message) > 128) {
|
if (strlen($message) > 128) {
|
||||||
api_err("The message must be less than 128 chars");
|
api_err("The message must be less than 128 chars");
|
||||||
@@ -472,7 +472,7 @@ if ($q == "getAddress") {
|
|||||||
if ($val < 0.00000001) {
|
if ($val < 0.00000001) {
|
||||||
api_err("Invalid value");
|
api_err("Invalid value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set alias
|
// set alias
|
||||||
if ($version==3) {
|
if ($version==3) {
|
||||||
$fee=10;
|
$fee=10;
|
||||||
@@ -632,7 +632,7 @@ if ($q == "getAddress") {
|
|||||||
$public_key=san($data['public_key']);
|
$public_key=san($data['public_key']);
|
||||||
$signature=san($data['signature']);
|
$signature=san($data['signature']);
|
||||||
$data=$data['data'];
|
$data=$data['data'];
|
||||||
|
|
||||||
api_echo(ec_verify($data, $signature, $public_key));
|
api_echo(ec_verify($data, $signature, $public_key));
|
||||||
} elseif ($q == "masternodes") {
|
} elseif ($q == "masternodes") {
|
||||||
/**
|
/**
|
||||||
@@ -662,7 +662,7 @@ if ($q == "getAddress") {
|
|||||||
*
|
*
|
||||||
* @apiSuccess {string} data alias
|
* @apiSuccess {string} data alias
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$public_key = $data['public_key'];
|
$public_key = $data['public_key'];
|
||||||
$account = $data['account'];
|
$account = $data['account'];
|
||||||
if (!empty($public_key) && strlen($public_key) < 32) {
|
if (!empty($public_key) && strlen($public_key) < 32) {
|
||||||
@@ -671,18 +671,29 @@ if ($q == "getAddress") {
|
|||||||
if (!empty($public_key)) {
|
if (!empty($public_key)) {
|
||||||
$account = $acc->get_address($public_key);
|
$account = $acc->get_address($public_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($account)) {
|
if (empty($account)) {
|
||||||
api_err("Invalid account id");
|
api_err("Invalid account id");
|
||||||
}
|
}
|
||||||
$account = san($account);
|
$account = san($account);
|
||||||
|
|
||||||
api_echo($acc->account2alias($account));
|
api_echo($acc->account2alias($account));
|
||||||
} elseif ($q === 'sanity') {
|
} elseif ($q === 'sanity') {
|
||||||
|
/**
|
||||||
|
* @api {get} /api.php?q=sanity 20. sanity
|
||||||
|
* @apiName sanity
|
||||||
|
* @apiGroup API
|
||||||
|
* @apiDescription Returns details about the node's sanity process.
|
||||||
|
*
|
||||||
|
* @apiSuccess {object} data A collection of data about the sanity process.
|
||||||
|
* @apiSuccess {boolean} data.sanity_running Whether the sanity process is currently running.
|
||||||
|
* @apiSuccess {number} data.last_sanity The timestamp for the last time the sanity process was run.
|
||||||
|
* @apiSuccess {boolean} data.sanity_sync Whether the sanity process is currently synchronising.
|
||||||
|
*/
|
||||||
$sanity = file_exists(__DIR__.'/tmp/sanity-lock');
|
$sanity = file_exists(__DIR__.'/tmp/sanity-lock');
|
||||||
|
|
||||||
$lastSanity = $db->single("SELECT val FROM config WHERE cfg='sanity_last'");
|
$lastSanity = (int)$db->single("SELECT val FROM config WHERE cfg='sanity_last'");
|
||||||
$sanitySync = $db->single("SELECT val FROM config WHERE cfg='sanity_sync'");
|
$sanitySync = (bool)$db->single("SELECT val FROM config WHERE cfg='sanity_sync'");
|
||||||
api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]);
|
api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]);
|
||||||
} elseif ($q=="node-info"){
|
} elseif ($q=="node-info"){
|
||||||
$dbversion=$db->single("SELECT val FROM config WHERE cfg='dbversion'");
|
$dbversion=$db->single("SELECT val FROM config WHERE cfg='dbversion'");
|
||||||
@@ -692,7 +703,7 @@ if ($q == "getAddress") {
|
|||||||
$mns=$db->single("SELECT COUNT(1) FROM masternode");
|
$mns=$db->single("SELECT COUNT(1) FROM masternode");
|
||||||
$mempool=$db->single("SELECT COUNT(1) FROM mempool");
|
$mempool=$db->single("SELECT COUNT(1) FROM mempool");
|
||||||
api_echo(["hostname"=>$hostname, "version"=>VERSION,"dbversion"=>$dbversion, "accounts"=>$acc, "transactions"=>$tr, "mempool"=>$mempool, "masternodes"=>$mns]);
|
api_echo(["hostname"=>$hostname, "version"=>VERSION,"dbversion"=>$dbversion, "accounts"=>$acc, "transactions"=>$tr, "mempool"=>$mempool, "masternodes"=>$mns]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
api_err("Invalid request");
|
api_err("Invalid request");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user