Only request needed fields from SN info

This cuts the size of the response by about 75%.
This commit is contained in:
Jason Rhinelander 2022-06-10 20:24:23 -03:00
parent 53f53f2a51
commit e56bf13e55
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
2 changed files with 14 additions and 1 deletions

View File

@ -238,8 +238,19 @@ bool NodeRPCProxy::update_all_service_nodes_cache(uint64_t height) const {
if (m_offline)
return false;
rpc::GET_SERVICE_NODES::request req{};
req.fields = rpc::GET_SERVICE_NODES::requested_fields_t{};
auto& f = *req.fields;
f.active = true;
f.contributors = true;
f.funded = true;
f.registration_height = true;
f.requested_unlock_height = true;
f.service_node_pubkey = true;
f.staking_requirement = true;
f.total_reserved = true;
try {
auto res = invoke_json_rpc<rpc::GET_SERVICE_NODES>({});
auto res = invoke_json_rpc<rpc::GET_SERVICE_NODES>(req);
m_all_service_nodes_cached_height = height;
m_all_service_nodes = std::move(res.service_node_states);
} catch (...) { return false; }

View File

@ -56,6 +56,8 @@ public:
bool get_fee_quantization_mask(uint64_t &fee_quantization_mask) const;
std::optional<cryptonote::hf> get_hardfork_version() const;
// Note that this service node responses only fills out fields that are used in wallet code, not
// the full service node records. (see node_rpc_proxy.cpp for the precise list).
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry>> get_service_nodes(std::vector<std::string> pubkeys) const;
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry>> get_all_service_nodes() const;
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry>> get_contributed_service_nodes(const std::string& contributor) const;