adding confirm_req to_string() (#3984)

Adding a to_string function to confirm_req class.

Co-authored-by: Dimitrios Siganos <dimitris@siganos.org>
This commit is contained in:
Ian Cunningham 2022-12-29 14:54:29 -06:00 committed by GitHub
commit 980481b0ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -940,6 +940,25 @@ std::size_t nano::confirm_req::size (nano::block_type type_a, std::size_t count)
return result;
}
std::string nano::confirm_req::to_string () const
{
std::string s = header.to_string ();
if (header.block_type () == nano::block_type::not_a_block)
{
for (auto && roots_hash : roots_hashes)
{
s += "\n" + roots_hash.first.to_string () + ":" + roots_hash.second.to_string ();
}
}
else
{
s += "\n" + block->to_json ();
}
return s;
}
/*
* confirm_ack
*/

View file

@ -198,6 +198,7 @@ public:
std::vector<std::pair<nano::block_hash, nano::root>> roots_hashes;
std::string roots_string () const;
static std::size_t size (nano::block_type, std::size_t = 0);
std::string to_string () const;
};
class confirm_ack final : public message