catchunks: pass versioned name to onDiscoverySuccess signal

refs: #4556
Change-Id: I599bafcf70647bd806236f87f24d7a22f73a3505
diff --git a/tools/chunks/catchunks/discover-version-iterative.cpp b/tools/chunks/catchunks/discover-version-iterative.cpp
index fddf08e..adeb48e 100644
--- a/tools/chunks/catchunks/discover-version-iterative.cpp
+++ b/tools/chunks/catchunks/discover-version-iterative.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -109,12 +109,28 @@
       std::cerr << "Found data with the latest version: " << m_latestVersion << std::endl;
 
     // we discovered at least one version. assume what we have is the latest.
-    this->emitSignal(onDiscoverySuccess, *m_latestVersionData);
+    this->emitSignal(onDiscoverySuccess, Name(interest.getName()).appendVersion(m_latestVersion));
   }
   else {
     DiscoverVersion::handleTimeout(interest, reason);
   }
 }
 
+void
+DiscoverVersionIterative::handleNack(const Interest& interest, const std::string& reason)
+{
+  if (m_foundVersion) {
+    // a version has been found and after a nack this version can be used as the latest.
+    if (isVerbose)
+      std::cerr << "Found data with the latest version: " << m_latestVersion << std::endl;
+
+    // we discovered at least one version. assume what we have is the latest.
+    this->emitSignal(onDiscoverySuccess, Name(interest.getName()).appendVersion(m_latestVersion));
+  }
+  else {
+    DiscoverVersion::handleNack(interest, reason);
+  }
+}
+
 } // namespace chunks
 } // namespace ndn