mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Included output hash and ledger info in output return message. (#284)
This commit is contained in:
@@ -136,8 +136,8 @@ namespace msg::usrmsg::json
|
||||
* Message format:
|
||||
* {
|
||||
* "type": "stat_response",
|
||||
* "lcl_seq_no": <lcl sequence no>,
|
||||
* "lcl_hash": "<lcl hash hex>"
|
||||
* "ledger_seq_no": <lcl sequence no>,
|
||||
* "ledger_hash": "<lcl hash hex>"
|
||||
* }
|
||||
*/
|
||||
void create_status_response(std::vector<uint8_t> &msg, const uint64_t lcl_seq_no, std::string_view lcl_hash)
|
||||
@@ -154,11 +154,11 @@ namespace msg::usrmsg::json
|
||||
msg += SEP_COLON;
|
||||
msg += version::HP_VERSION;
|
||||
msg += SEP_COMMA;
|
||||
msg += msg::usrmsg::FLD_LCL_SEQ;
|
||||
msg += msg::usrmsg::FLD_LEDGER_SEQ_NO;
|
||||
msg += SEP_COLON_NOQUOTE;
|
||||
msg += std::to_string(lcl_seq_no);
|
||||
msg += SEP_COMMA_NOQUOTE;
|
||||
msg += msg::usrmsg::FLD_LCL_HASH;
|
||||
msg += msg::usrmsg::FLD_LEDGER_HASH;
|
||||
msg += SEP_COLON;
|
||||
msg += util::to_hex(lcl_hash);
|
||||
msg += SEP_COMMA;
|
||||
@@ -323,15 +323,21 @@ namespace msg::usrmsg::json
|
||||
* Message format:
|
||||
* {
|
||||
* "type": "contract_output",
|
||||
* "lcl_seq_no": <integer>,
|
||||
* "lcl_hash": "<lcl hash hex>",
|
||||
* "outputs": ["<output string 1>", "<output string 2>", ...], // The output order is the hash order.
|
||||
* "hashes": [<hex merkle hash tree>], // Always includes user's output hash [output hash = hash(pubkey+all outputs for the user)]
|
||||
* "ledger_seq_no": <integer>,
|
||||
* "ledger_hash": "<lcl hash hex>",
|
||||
* "outputs": ["<output string 1>", "<output string 2>", ...], // The output order is the hash generation order.
|
||||
* "output_hash": "<hex hash of user's outputs>", [output hash = hash(pubkey+all outputs for the user)]
|
||||
* "hash_tree": [<hex merkle hash tree>], // Collapsed merkle tree with user's hash element marked as null.
|
||||
* "unl_sig": [["<pubkey hex>", "<sig hex>"], ...] // UNL pubkeys and signatures of root hash.
|
||||
* }
|
||||
* @param content The contract binary output content to be put in the message.
|
||||
* @param hash This user's combined output hash. [output hash = hash(pubkey+all outputs for the user)]
|
||||
* @param outputs List of outputs for the user.
|
||||
* @param hash_root Root node of the collapsed merkle hash tree.
|
||||
* @param unl_sig List of unl signatures issued on the root hash. (root hash = combined merkle hash of hashes of all users)
|
||||
* @param lcl_seq_no Current ledger seq no.
|
||||
* @param lcl_hash Current ledger hash.
|
||||
*/
|
||||
void create_contract_output_container(std::vector<uint8_t> &msg, const ::std::vector<std::string_view> &outputs,
|
||||
void create_contract_output_container(std::vector<uint8_t> &msg, std::string_view hash, const ::std::vector<std::string> &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)
|
||||
{
|
||||
@@ -341,11 +347,11 @@ namespace msg::usrmsg::json
|
||||
msg += SEP_COLON;
|
||||
msg += msg::usrmsg::MSGTYPE_CONTRACT_OUTPUT;
|
||||
msg += SEP_COMMA;
|
||||
msg += msg::usrmsg::FLD_LCL_SEQ;
|
||||
msg += msg::usrmsg::FLD_LEDGER_SEQ_NO;
|
||||
msg += SEP_COLON_NOQUOTE;
|
||||
msg += std::to_string(lcl_seq_no);
|
||||
msg += SEP_COMMA_NOQUOTE;
|
||||
msg += msg::usrmsg::FLD_LCL_HASH;
|
||||
msg += msg::usrmsg::FLD_LEDGER_HASH;
|
||||
msg += SEP_COLON;
|
||||
msg += util::to_hex(lcl_hash);
|
||||
msg += SEP_COMMA;
|
||||
@@ -379,10 +385,15 @@ namespace msg::usrmsg::json
|
||||
|
||||
msg += "],\"";
|
||||
|
||||
msg += msg::usrmsg::FLD_HASHES;
|
||||
msg += "\":";
|
||||
msg += msg::usrmsg::FLD_OUTPUT_HASH;
|
||||
msg += SEP_COLON;
|
||||
msg += util::to_hex(hash);
|
||||
msg += SEP_COMMA;
|
||||
|
||||
msg += msg::usrmsg::FLD_HASH_TREE;
|
||||
msg += SEP_COLON_NOQUOTE;
|
||||
populate_output_hash_array(msg, hash_root);
|
||||
msg += ",\"";
|
||||
msg += SEP_COMMA_NOQUOTE;
|
||||
|
||||
msg += msg::usrmsg::FLD_UNL_SIG;
|
||||
msg += "\":[";
|
||||
@@ -391,7 +402,7 @@ namespace msg::usrmsg::json
|
||||
const auto &sig = unl_sig[i]; // Pubkey and Signature pair.
|
||||
msg += "[\"";
|
||||
msg += util::to_hex(sig.first);
|
||||
msg += "\",\"";
|
||||
msg += SEP_COMMA;
|
||||
msg += util::to_hex(sig.second);
|
||||
msg += "\"]";
|
||||
|
||||
@@ -845,9 +856,18 @@ namespace msg::usrmsg::json
|
||||
{
|
||||
if (node.children.empty())
|
||||
{
|
||||
msg += "\"";
|
||||
msg += util::to_hex(node.hash);
|
||||
msg += "\"";
|
||||
if (node.is_retained)
|
||||
{
|
||||
// The retained node is serialized as null.
|
||||
// This is so the client can identify the self-hash position within the hash tree.
|
||||
msg += "null";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += "\"";
|
||||
msg += util::to_hex(node.hash);
|
||||
msg += "\"";
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user