chunks: consolidate accounting of received data into onData()
Change-Id: Ib47381d3f69b482d60af8b07d002135944b17604
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index c0512cc..e520bfe 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -35,10 +35,10 @@
PipelineInterests::PipelineInterests(Face& face)
: m_face(face)
+ , m_hasFinalBlockId(false)
, m_lastSegmentNo(0)
, m_nReceived(0)
, m_receivedSize(0)
- , m_hasFinalBlockId(false)
, m_nextSegmentNo(0)
, m_excludedSegmentNo(0)
, m_isStopping(false)
@@ -48,11 +48,11 @@
PipelineInterests::~PipelineInterests() = default;
void
-PipelineInterests::run(const Data& data, DataCallback onData, FailureCallback onFailure)
+PipelineInterests::run(const Data& data, DataCallback dataCb, FailureCallback failureCb)
{
- BOOST_ASSERT(onData != nullptr);
- m_onData = std::move(onData);
- m_onFailure = std::move(onFailure);
+ BOOST_ASSERT(dataCb != nullptr);
+ m_onData = std::move(dataCb);
+ m_onFailure = std::move(failureCb);
m_prefix = data.getName().getPrefix(-1);
m_excludedSegmentNo = getSegmentFromPacket(data);
@@ -61,11 +61,11 @@
m_hasFinalBlockId = true;
}
+ onData(data);
+
// record the start time of the pipeline
m_startTime = time::steady_clock::now();
- m_nReceived++;
- m_receivedSize += data.getContent().value_size();
doRun();
}
@@ -90,6 +90,15 @@
}
void
+PipelineInterests::onData(const Data& data)
+{
+ m_nReceived++;
+ m_receivedSize += data.getContent().value_size();
+
+ m_onData(data);
+}
+
+void
PipelineInterests::onFailure(const std::string& reason)
{
if (m_isStopping)