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)
     {
diff --git a/model/sync-digest.h b/model/sync-digest.h
index 15c7278..42cfd81 100644
--- a/model/sync-digest.h
+++ b/model/sync-digest.h
@@ -108,6 +108,14 @@
   inline Digest &
   operator << (uint32_t value);
 
+  /**
+   * @brief Checks if the stored hash is zero-root hash
+   *
+   * Zero-root hash is a valid hash that optimally represents an empty state
+   */
+  bool
+  zero () const;
+  
 private:
   Digest &
   operator = (Digest &digest) { return *this; }
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 0f71b95..3638045 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -83,13 +83,23 @@
 {
   //cout << "SyncLogic::processSyncInterest " << timedProcessing << endl;
   recursive_mutex::scoped_lock lock (m_stateMutex);
-    
-  if (*m_state.getDigest() == *digest)
-  {
-    m_syncInterestTable.insert (interestName);
-    return;
-  }
 
+  if (*m_state.getDigest() == *digest)
+    {
+      // cout << interestName << "\n";
+      m_syncInterestTable.insert (interestName);
+      return;
+    }
+
+  // Special case when state is not empty and we have received request with zero-root digest
+  if (digest->zero ())
+    {
+      m_ccnxHandle->publishData (interestName + "/state",
+                                 lexical_cast<string> (m_state),
+                                 m_syncResponseFreshness);
+      return;
+    }
+  
   DiffStateContainer::iterator stateInDiffLog = m_log.find (digest);
 
   if (stateInDiffLog != m_log.end ())