From f76c75f28c157cadbe9b6b1483d34c82e90cfc30 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 8 Oct 2020 23:08:02 -0300 Subject: [PATCH] LNS_OWNERS_TO_NAMES rpc fixes - Add missing expiration_height serialization. - Add "include_expired" field (to match LNS_NAMES_TO_OWNERS). --- src/rpc/core_rpc_server.cpp | 4 +++- src/rpc/core_rpc_server_commands_defs.cpp | 2 ++ src/rpc/core_rpc_server_commands_defs.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 0e011d1a6..391dda547 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -3414,7 +3414,9 @@ namespace cryptonote { namespace rpc { } lns::name_system_db &db = m_core.get_blockchain_storage().name_system_db(); - auto height = m_core.get_current_blockchain_height(); + std::optional height; + if (!req.include_expired) height = m_core.get_current_blockchain_height(); + std::vector records = db.get_mappings_by_owners(owners, height); for (auto &record : records) { diff --git a/src/rpc/core_rpc_server_commands_defs.cpp b/src/rpc/core_rpc_server_commands_defs.cpp index 7e0689cad..5f6715e26 100644 --- a/src/rpc/core_rpc_server_commands_defs.cpp +++ b/src/rpc/core_rpc_server_commands_defs.cpp @@ -1337,6 +1337,7 @@ KV_SERIALIZE_MAP_CODE_END() KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::request) KV_SERIALIZE(entries) + KV_SERIALIZE(include_expired) KV_SERIALIZE_MAP_CODE_END() @@ -1348,6 +1349,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::response_entry) KV_SERIALIZE(backup_owner) KV_SERIALIZE(encrypted_value) KV_SERIALIZE(update_height) + KV_SERIALIZE(expiration_height) KV_SERIALIZE(txid) KV_SERIALIZE_MAP_CODE_END() diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 42cb4df29..600b38960 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -2463,6 +2463,7 @@ namespace rpc { struct request { std::vector entries; // The owner's public key to find all Loki Name Service entries for. + bool include_expired; // Optional: if provided and true, include entries in the results even if they are expired KV_MAP_SERIALIZABLE };