From 980481b0ea97126d3e27668a4f7f1ec46f832e3a Mon Sep 17 00:00:00 2001 From: Ian Cunningham Date: Thu, 29 Dec 2022 14:54:29 -0600 Subject: [PATCH] adding confirm_req to_string() (#3984) Adding a to_string function to confirm_req class. Co-authored-by: Dimitrios Siganos --- nano/node/messages.cpp | 19 +++++++++++++++++++ nano/node/messages.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/nano/node/messages.cpp b/nano/node/messages.cpp index a02f943a..c1d77957 100644 --- a/nano/node/messages.cpp +++ b/nano/node/messages.cpp @@ -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 */ diff --git a/nano/node/messages.hpp b/nano/node/messages.hpp index 3395fc5b..fb236803 100644 --- a/nano/node/messages.hpp +++ b/nano/node/messages.hpp @@ -198,6 +198,7 @@ public: std::vector> 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