From ac3bbfb09b3e083cefa81f0636c3a3ed819c06f7 Mon Sep 17 00:00:00 2001 From: sproxet Date: Sun, 25 Sep 2022 14:45:50 +0700 Subject: [PATCH] Make client-api's getElysiumPropertyInfo take multiple values at once. --- src/client-api/elysium.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/client-api/elysium.cpp b/src/client-api/elysium.cpp index 5813ef0c12..d29aaa87ce 100644 --- a/src/client-api/elysium.cpp +++ b/src/client-api/elysium.cpp @@ -81,17 +81,36 @@ UniValue getPropertyData(uint256 propertyCreationTxid) { UniValue getElysiumPropertyInfo(Type type, const UniValue& data, const UniValue& auth, bool fHelp) { LOCK(cs_main); - if (data.exists("propertyId")) { - return getPropertyData(data["propertyId"].get_int64()); + UniValue ret = UniValue::VARR; + + if (data.exists("propertyIds")) { + for (const UniValue& propertyId: data["propertyIds"].get_array().getValues()) { + uint32_t id = propertyId.get_int(); + + try { + ret.push_back(getPropertyData(id)); + } catch (UniValue& e) { + LogPrintf("Failed to get info about property id %d\n", id); + } + } } - if (data.exists("propertyCreationTxid")) { - uint256 txid; - txid.SetHex(data["propertyCreationTxid"].get_str()); - return getPropertyData(txid); + if (data.exists("propertyCreationTxids")) { + for (const UniValue &propertyId: data["propertyCreationTxids"].get_array().getValues()) { + const std::string& id = propertyId.get_str(); + + uint256 txid; + txid.SetHex(id); + + try { + ret.push_back(getPropertyData(txid)); + } catch (UniValue &e) { + LogPrintf("Failed to get info about property %s\n", id); + } + } } - throw JSONAPIError(API_INVALID_PARAMS, "propertyId or propertyCreationTxid must be specified"); + return ret; } UniValue createElysiumProperty(Type type, const UniValue &data, const UniValue &auth, bool fHelp) {