Merge pull request #1607 from jagerman/aux-ping-errors-dev

Allow lokinet/ss to send an error ping
This commit is contained in:
Jason Rhinelander 2022-10-17 13:39:03 -03:00 committed by GitHub
commit 7427fb051b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -2721,6 +2721,7 @@ namespace cryptonote::rpc {
std::array<uint16_t, 3> cur_version,
std::array<uint16_t, 3> required,
std::string_view ed25519_pubkey,
std::string_view error,
std::string_view name,
std::atomic<std::time_t>& update,
std::chrono::seconds lifetime,
@ -2728,7 +2729,13 @@ namespace cryptonote::rpc {
{
std::string status{};
std::string our_ed25519_pubkey = tools::type_to_hex(core.get_service_keys().pub_ed25519);
if (cur_version < required) {
if (!error.empty()) {
status = fmt::format("Error: {}", error);
MERROR(fmt::format("{0} reported an error: {1}. Check {0} logs for more details.", name, error));
update = 0; // Reset our last ping time to 0 so that we won't send a ping until we get
// success back again (even if we had an earlier acceptable ping within the
// cutoff time).
else if (cur_version < required) {
status = fmt::format("Outdated {}. Current: {}.{}.{} Required: {}.{}.{}", name,
cur_version[0], cur_version[1], cur_version[2],
required[0], required[1], required[2]);
@ -2760,6 +2767,7 @@ namespace cryptonote::rpc {
storage_server_ping.response["status"] = handle_ping(m_core,
storage_server_ping.request.version, service_nodes::MIN_STORAGE_SERVER_VERSION,
storage_server_ping.request.ed25519_pubkey,
storage_server_ping.request.error,
"Storage Server", m_core.m_last_storage_server_ping, m_core.get_net_config().UPTIME_PROOF_FREQUENCY,
[this, &storage_server_ping](bool significant) {
m_core.m_storage_https_port = storage_server_ping.request.https_port;
@ -2775,6 +2783,7 @@ namespace cryptonote::rpc {
lokinet_ping.response["status"] = handle_ping(m_core,
lokinet_ping.request.version, service_nodes::MIN_LOKINET_VERSION,
lokinet_ping.request.ed25519_pubkey,
lokinet_ping.request.error,
"Lokinet", m_core.m_last_lokinet_ping, m_core.get_net_config().UPTIME_PROOF_FREQUENCY,
[this](bool significant) { if (significant) m_core.reset_proof_interval(); });
}

View File

@ -239,15 +239,19 @@ namespace cryptonote::rpc {
}
void parse_request(LOKINET_PING& lokinet_ping, rpc_input in){
get_values(in, "version", lokinet_ping.request.version);
get_values(in, "ed25519_pubkey", lokinet_ping.request.ed25519_pubkey);
get_values(in,
"ed25519_pubkey", lokinet_ping.request.ed25519_pubkey,
"error", lokinet_ping.request.error,
"version", lokinet_ping.request.version);
}
void parse_request(STORAGE_SERVER_PING& storage_server_ping, rpc_input in){
get_values(in, "version", storage_server_ping.request.version);
get_values(in, "https_port", storage_server_ping.request.https_port);
get_values(in, "omq_port", storage_server_ping.request.omq_port);
get_values(in, "ed25519_pubkey", storage_server_ping.request.ed25519_pubkey);
get_values(in,
"ed25519_pubkey", storage_server_ping.request.ed25519_pubkey,
"error", storage_server_ping.request.error,
"https_port", storage_server_ping.request.https_port,
"omq_port", storage_server_ping.request.omq_port,
"version", storage_server_ping.request.version);
}
void parse_request(PRUNE_BLOCKCHAIN& prune_blockchain, rpc_input in){

View File

@ -1894,6 +1894,7 @@ namespace cryptonote::rpc {
uint16_t https_port; // Storage server https port to include in uptime proofs
uint16_t omq_port; // Storage Server oxenmq port to include in uptime proofs
std::string ed25519_pubkey; // Service node Ed25519 pubkey for verifying that storage server is using the right one
std::string error; // If given and non-empty then this is an error message telling oxend to *not* submit an uptime proof and to report this error in the logs instead. Oxend won't send proofs until it gets another ping (without an error).
} request;
};
@ -1917,6 +1918,7 @@ namespace cryptonote::rpc {
{
std::array<uint16_t, 3> version; // Lokinet version
std::string ed25519_pubkey; // Service node Ed25519 pubkey for verifying that lokinet is using the right one
std::string error; // If given and non-empty then this is an error message telling oxend to *not* submit an uptime proof and to report this error in the logs instead. Oxend won't send proofs until it gets another ping (without an error).
} request;
};