PSync: react to NACK and make jitter shorter

Change-Id: If358d3f189f174e6f36b5d94c6d73d8fba358013
diff --git a/PSync/full-producer.cpp b/PSync/full-producer.cpp
index c31504c..205f819 100644
--- a/PSync/full-producer.cpp
+++ b/PSync/full-producer.cpp
@@ -41,10 +41,8 @@
   : ProducerBase(expectedNumEntries, face, syncPrefix, userPrefix, syncReplyFreshness)
   , m_syncInterestLifetime(syncInterestLifetime)
   , m_onUpdate(onUpdateCallBack)
+  , m_jitter(100, 500)
 {
-  int jitter = m_syncInterestLifetime.count() * .20;
-  m_jitter = std::uniform_int_distribution<>(-jitter, jitter);
-
   m_registeredPrefix = m_face.setInterestFilter(
                          ndn::InterestFilter(m_syncPrefix).allowLoopback(false),
                          std::bind(&FullProducer::onSyncInterest, this, _1, _2),
@@ -116,8 +114,13 @@
     onSyncData(syncInterest, bufferPtr);
   });
 
-  m_fetcher->onError.connect([] (uint32_t errorCode, const std::string& msg) {
+  m_fetcher->onError.connect([this] (uint32_t errorCode, const std::string& msg) {
     NDN_LOG_ERROR("Cannot fetch sync data, error: " << errorCode << " message: " << msg);
+    if (errorCode == SegmentFetcher::ErrorCode::NACK_ERROR) {
+      auto after = ndn::time::milliseconds(m_jitter(m_rng));
+      NDN_LOG_DEBUG("Schedule sync interest after: " << after);
+      m_scheduledSyncInterestId = m_scheduler.schedule(after, [this] { sendSyncInterest(); });
+    }
   });
 
   NDN_LOG_DEBUG("sendFullSyncInterest, nonce: " << syncInterest.getNonce() <<