1
0
Fork 0
forked from lthn/blockchain

rewritten prining function to avoid binary output

This commit is contained in:
crypro.zoidberg 2019-02-14 04:43:31 +01:00
parent 336b3b7d67
commit d1d048f4b0

View file

@ -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<typename container_t>
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();
}
}