chunks: consolidate accounting of received data into onData()
Change-Id: Ib47381d3f69b482d60af8b07d002135944b17604
diff --git a/tools/chunks/catchunks/consumer.cpp b/tools/chunks/catchunks/consumer.cpp
index 6132d82..ce01583 100644
--- a/tools/chunks/catchunks/consumer.cpp
+++ b/tools/chunks/catchunks/consumer.cpp
@@ -46,7 +46,11 @@
m_nextToPrint = 0;
m_bufferedData.clear();
- m_discover->onDiscoverySuccess.connect(bind(&Consumer::startPipeline, this, _1));
+ m_discover->onDiscoverySuccess.connect([this] (const Data& data) {
+ m_pipeline->run(data,
+ [this] (const Data& data) { handleData(data); },
+ [] (const std::string& msg) { BOOST_THROW_EXCEPTION(std::runtime_error(msg)); });
+ });
m_discover->onDiscoveryFailure.connect([] (const std::string& msg) {
BOOST_THROW_EXCEPTION(std::runtime_error(msg));
});
@@ -54,16 +58,6 @@
}
void
-Consumer::startPipeline(const Data& data)
-{
- this->handleData(data);
-
- m_pipeline->run(data,
- [this] (const Interest&, const Data& data) { this->handleData(data); },
- [] (const std::string& msg) { BOOST_THROW_EXCEPTION(std::runtime_error(msg)); });
-}
-
-void
Consumer::handleData(const Data& data)
{
auto dataPtr = data.shared_from_this();
@@ -82,7 +76,7 @@
m_bufferedData[getSegmentFromPacket(data)] = dataPtr;
writeInOrderData();
},
- [] (const Data& data, const security::v2::ValidationError& error) {
+ [] (const Data&, const security::v2::ValidationError& error) {
BOOST_THROW_EXCEPTION(DataValidationError(error));
});
}