Adding a pecial case when state is not empty and we have received request with zero-root digest
If zero-root digest is received and the current state is not empty, then
we immediately reply with the full-state message
diff --git a/model/sync-digest.cc b/model/sync-digest.cc
index 6da6e78..7a5b605 100644
--- a/model/sync-digest.cc
+++ b/model/sync-digest.cc
@@ -128,6 +128,18 @@
return m_buffer == 0;
}
+bool
+Digest::zero () const
+{
+ if (m_buffer == 0)
+ BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
+ << errmsg_info_str ("Digest has not been yet finalized"));
+
+ if (m_hashLength == 1 && m_buffer[0] == 0)
+ return true;
+}
+
+
void
Digest::reset ()
{
@@ -159,16 +171,11 @@
<< errmsg_info_str ("EVP_DigestFinal_ex returned error")
<< errmsg_info_int (ok));
}
-
+
std::size_t
Digest::getHash () const
{
- if (m_buffer == 0)
- BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
- << errmsg_info_str ("Digest has not been yet finalized"));
-
- if (m_hashLength == 1 && m_buffer[0] == 0)
- return 0;
+ if (zero ()) return 0;
if (sizeof (std::size_t) > m_hashLength)
{