Skip to content

Commit

Permalink
Make testing_quorum JSON serialization work for input
Browse files Browse the repository at this point in the history
The block explorer uses loki's KV serialization structs for its RPC
commands, but testing_quorum was only doing outbound serialization of
validators/workers.  This adds the missing inbound serialization code.
  • Loading branch information
jagerman committed Jul 12, 2019
1 parent 943e126 commit 5e2d584
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/cryptonote_core/service_node_quorum_cop.h
Expand Up @@ -57,13 +57,29 @@ namespace service_nodes
END_SERIALIZE()

BEGIN_KV_SERIALIZE_MAP()
std::vector<std::string> validators(this_ref.validators.size());
for (size_t i = 0; i < this_ref.validators.size(); i++) validators[i] = epee::string_tools::pod_to_hex(this_ref.validators[i]);
KV_SERIALIZE_VALUE(validators);
std::vector<std::string> validators, workers;
if (is_store)
{
validators.reserve(this_ref.validators.size());
workers.reserve(this_ref.workers.size());
for (auto &v : this_ref.validators)
validators.push_back(epee::string_tools::pod_to_hex(v));
for (auto &w : this_ref.workers)
workers.push_back(epee::string_tools::pod_to_hex(w));
}

std::vector<std::string> workers(this_ref.workers.size());
for (size_t i = 0; i < this_ref.workers.size(); i++) workers[i] = epee::string_tools::pod_to_hex(this_ref.workers[i]);
KV_SERIALIZE_VALUE(validators);
KV_SERIALIZE_VALUE(workers);

if (!is_store)
{
this_ref.validators.resize(validators.size());
this_ref.workers.resize(workers.size());
for (size_t i = 0; i < validators.size(); i++)
epee::string_tools::hex_to_pod(validators[i], this_ref.validators[i]);
for (size_t i = 0; i < workers.size(); i++)
epee::string_tools::hex_to_pod(workers[i], this_ref.workers[i]);
}
END_KV_SERIALIZE_MAP()
};

Expand Down

0 comments on commit 5e2d584

Please sign in to comment.