From d1d048f4b05debdb440794da0ef259ec952afb07 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 14 Feb 2019 04:43:31 +0100 Subject: [PATCH] rewritten prining function to avoid binary output --- .../currency_protocol_defs_print.h | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/currency_protocol/currency_protocol_defs_print.h b/src/currency_protocol/currency_protocol_defs_print.h index 67442ecf..05ef76ee 100644 --- a/src/currency_protocol/currency_protocol_defs_print.h +++ b/src/currency_protocol/currency_protocol_defs_print.h @@ -23,17 +23,38 @@ namespace currency { ss << "UNPARSED" << ENDL; } - ss << get_block_hash(b) << ", parent: " << b.prev_id; + ss << get_block_hash(b) << "{....parent: " << b.prev_id << "....}" << ENDL; i++; } return ss.str(); } + template + std::string print_container_of_hashs(const container_t& cont, size_t indent) + { + std::stringstream ss; + std::string indent_str(indent, ' '); + for (const auto& h : cont) + { + ss << indent_str << h << ENDL; + } + return ss.str(); + } + + inline + std::string print_kv_structure(const NOTIFY_REQUEST_GET_OBJECTS::request& v) + { + std::stringstream ss; + ss << "blocks: {" << ENDL << print_container_of_hashs(v.blocks, 2) << ENDL << "}"; + ss << "txs: {" << ENDL << print_container_of_hashs(v.txs, 2) << ENDL << "}"; + return ss.str(); + } + inline std::string print_kv_structure(const NOTIFY_RESPONSE_GET_OBJECTS::request& v) { - std::stringstream ss; + std::stringstream ss; ss << "\"blocks\":{" << ENDL << print_complete_block_entry_list(v.blocks) << ENDL << "}, " << ENDL; ss << "\"missed_ids\":" << ENDL; ::epee::serialization::dump_as_json(ss, v.missed_ids, 2); @@ -41,4 +62,28 @@ namespace currency return ss.str(); } + inline + std::string print_kv_structure(const NOTIFY_REQUEST_CHAIN::request& v) + { + std::stringstream ss; + size_t i = 0; + ss << "block_ids: {" << ENDL << print_container_of_hashs(v.block_ids, 2) << ENDL << "}"; + return ss.str(); + } + inline + std::string print_kv_structure(const NOTIFY_RESPONSE_CHAIN_ENTRY::request& v) + { + std::stringstream ss; + ss << "start_height:" << v.start_height << ENDL; + ss << "total_height:" << v.total_height << ENDL; + ss << "block_ids: {" << ENDL; + for (const block_context_info& bei : v.m_block_ids) + { + ss << bei.h << ":" << bei.cumul_size << ENDL; + } + ss << "}"; + return ss.str(); + } + + } \ No newline at end of file