add GZip support for protobuf
use GZip in serializing SyncStateMsg

use BytesPtr

Change-Id: I37dc41bda4a811b10308bc42e42f320cad986dba
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 5a195f6..4aaf1a5 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -94,7 +94,7 @@
 
   // reply sync Interest with oldHash as last component
   Name syncName = Name (m_syncPrefix)(oldHash->GetHash(), oldHash->GetHashBytes());
-  BytesPtr syncData = serializeMsg (*msg);
+  BytesPtr syncData = serializeGZipMsg (*msg);
 
   m_ccnx->publishData(syncName, *syncData, FRESHNESS);
   _LOG_DEBUG ("[" << m_log->GetLocalName () << "] localStateChanged ");
@@ -141,7 +141,7 @@
     // we know the hash, should reply everything
     SyncStateMsgPtr msg = m_log->FindStateDifferences(*(Hash::Origin), *m_rootHash);
 
-    BytesPtr syncData = serializeMsg (*msg);
+    BytesPtr syncData = serializeGZipMsg (*msg);
     m_ccnx->publishData(name, *syncData, FRESHNESS);
     _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes " << hash.shortHash ());
     // _LOG_TRACE (msg);
@@ -171,7 +171,7 @@
     _LOG_TRACE ("found hash in sync log");
     SyncStateMsgPtr msg = m_log->FindStateDifferences(*hash, *m_rootHash);
 
-    BytesPtr syncData = serializeMsg (*msg);
+    BytesPtr syncData = serializeGZipMsg (*msg);
     m_ccnx->publishData(name, *syncData, FRESHNESS);
     _LOG_TRACE (m_log->GetLocalName () << " publishes: " << hash->shortHash ());
     _LOG_TRACE (msg);
@@ -252,9 +252,8 @@
 void
 SyncCore::handleStateData(const Bytes &content)
 {
-  SyncStateMsgPtr msg(new SyncStateMsg);
-  bool success = msg->ParseFromArray(head(content), content.size());
-  if(!success)
+  SyncStateMsgPtr msg = deserializeGZipMsg<SyncStateMsg>(content);
+  if(!(msg))
   {
     // ignore misformed SyncData
     _LOG_ERROR ("Misformed SyncData");