From 7e3b52844e4853084247cd8257dbe8b21d24fd9b Mon Sep 17 00:00:00 2001 From: Asias He Date: Thu, 5 Mar 2015 09:52:10 +0800 Subject: [PATCH] gossip: Move gossip_digest_serialization_helper to gossip_digest.hh It makes more sense to put the helper near class gossip_digest not class gossip_digest_syn. The helper is used by class gossip_digest_ack as well. The moving makes the including more clear. --- gms/gossip_digest.hh | 26 ++++++++++++++++++++++++++ gms/gossip_digest_syn.hh | 27 --------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/gms/gossip_digest.hh b/gms/gossip_digest.hh index b6a926c10c..a887c91dc2 100644 --- a/gms/gossip_digest.hh +++ b/gms/gossip_digest.hh @@ -86,4 +86,30 @@ public: } }; // class gossip_digest +// serialization helper for std::vector +class gossip_digest_serialization_helper { +public: + static void serialize(std::ostream& out, const std::vector& digests) { + serialize_int32(out, int32_t(digests.size())); + for (auto& digest : digests) { + digest.serialize(out); + } + } + + static std::vector deserialize(std::istream& in) { + int32_t size = deserialize_int32(in); + std::vector digests; + for (int32_t i = 0; i < size; ++i) + digests.push_back(gossip_digest::deserialize(in)); + return digests; + } + + static size_t serialized_size(const std::vector& digests) { + size_t size = serialize_int32_size; + for (auto& digest : digests) + size += digest.serialized_size(); + return size; + } +}; + } // namespace gms diff --git a/gms/gossip_digest_syn.hh b/gms/gossip_digest_syn.hh index 072d3ea99b..2506f60f8d 100644 --- a/gms/gossip_digest_syn.hh +++ b/gms/gossip_digest_syn.hh @@ -27,33 +27,6 @@ namespace gms { -// serialization helper for std::vector -class gossip_digest_serialization_helper { -public: - static void serialize(std::ostream& out, const std::vector& digests) { - serialize_int32(out, int32_t(digests.size())); - for (auto& digest : digests) { - digest.serialize(out); - } - } - - static std::vector deserialize(std::istream& in) { - int32_t size = deserialize_int32(in); - std::vector digests; - for (int32_t i = 0; i < size; ++i) - digests.push_back(gossip_digest::deserialize(in)); - return digests; - } - - static size_t serialized_size(const std::vector& digests) { - size_t size = serialize_int32_size; - for (auto& digest : digests) - size += digest.serialized_size(); - return size; - } -}; - - /** * This is the first message that gets sent out as a start of the Gossip protocol in a * round.