Files
hpcore/src/msg/json/usrmsg_json.hpp
Ravin Perera 948113398c Ledger query infrastructure. (#275)
* Added json ledger query param parser.

* Added initial query response creation.

* Updated client lib.

* Implemented get ledger by seq no.

* Added ledger query execution wrappers.

* Included log record info.

* Fixed empty output hash issue.

* Added bson support.

* Added db file existance check.

* Added requesy/reply tracking for queries in client lib.

* Improved multi connection usage in client lib.

* Added genesis ledger query support.

* Updated naming convention of query result fields.

* Comments.

* Used sqlite bind() for query param.

* Used binary hashes in ledger sqlite db.

* Missing const.
2021-03-29 11:20:15 +05:30

56 lines
2.6 KiB
C++

#ifndef _HP_MSG_JSON_USRMSG_JSON_
#define _HP_MSG_JSON_USRMSG_JSON_
#include "../../pchheader.hpp"
#include "../../util/merkle_hash_tree.hpp"
#include "../../ledger/ledger_query.hpp"
namespace msg::usrmsg::json
{
void create_user_challenge(std::vector<uint8_t> &msg, std::string &challenge);
void create_server_challenge_response(std::vector<uint8_t> &msg, const std::string &original_challenge);
void create_status_response(std::vector<uint8_t> &msg, const uint64_t lcl_seq_no, std::string_view lcl_hash);
void create_contract_input_status(std::vector<uint8_t> &msg, std::string_view status, std::string_view reason,
std::string_view input_sig);
void create_contract_read_response_container(std::vector<uint8_t> &msg, std::string_view content);
void create_contract_output_container(std::vector<uint8_t> &msg, const ::std::vector<std::string_view> &outputs,
const util::merkle_hash_node &hash_root, const std::vector<std::pair<std::string, std::string>> &unl_sig,
const uint64_t lcl_seq_no, std::string_view lcl_hash);
void create_unl_list_container(std::vector<uint8_t> &msg, const ::std::set<std::string> &unl_list);
void create_ledger_query_response(std::vector<uint8_t> &msg, std::string_view reply_for,
const ledger::query::query_result &result);
int verify_user_challenge(std::string &extracted_pubkeyhex, std::string &extracted_protocol, std::string &extracted_server_challenge,
std::string_view response, std::string_view original_challenge);
int parse_user_message(jsoncons::json &d, std::string_view message);
int extract_type(std::string &extracted_type, const jsoncons::json &d);
int extract_read_request(std::string &extracted_content, const jsoncons::json &d);
int extract_signed_input_container(std::string &extracted_input_container, std::string &extracted_sig,
const jsoncons::json &d);
int extract_input_container(std::string &input, std::string &nonce,
uint64_t &max_lcl_seq_no, std::string_view contentjson);
int extract_ledger_query(ledger::query::query_request &extracted_query, std::string &extracted_id, const jsoncons::json &d);
bool is_json_string(std::string_view content);
void populate_output_hash_array(std::vector<uint8_t> &msg, const util::merkle_hash_node &node);
void populate_query_results(std::vector<uint8_t> &msg, const std::vector<ledger::query::query_result_record> &results);
} // namespace msg::usrmsg::json
#endif