handles: consolidate command prefix registrations
Previously, each command handle performs prefix registrations
separately, creating an excessive number of FIB entries in NFD.
This commit consolidates those registrations into one place,
and uses ndn::Face to dispatch Interests to command handlers.
refs #2023
Change-Id: Ia74ff970797eceac4df260e84dec727952d96489
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 862616a..a398f0b 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-handle.cpp
@@ -54,22 +54,6 @@
bind(&WriteHandle::onValidationFailed, this, _1, _2));
}
-// onRegisterFailed.
-void
-WriteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
-{
- std::cerr << reason << std::endl;
- BOOST_THROW_EXCEPTION(Error("Insert prefix registration failed"));
-}
-
-// onRegisterFailed for insert.
-void
-WriteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
-{
- std::cerr << reason << std::endl;
- BOOST_THROW_EXCEPTION(Error("Insert check prefix registration failed"));
-}
-
void
WriteHandle::onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix)
{
@@ -201,18 +185,10 @@
void
WriteHandle::listen(const Name& prefix)
{
- Name insertPrefix;
- insertPrefix.append(prefix).append("insert");
- ndn::InterestFilter filter_insert(insertPrefix);
- getFace().setInterestFilter(filter_insert,
- bind(&WriteHandle::onInterest, this, _1, _2),
- bind(&WriteHandle::onRegisterFailed, this, _1, _2));
- Name insertCheckPrefix;
- insertCheckPrefix.append(prefix).append("insert check");
- ndn::InterestFilter filter_insertCheck(insertCheckPrefix);
- getFace().setInterestFilter(filter_insertCheck,
- bind(&WriteHandle::onCheckInterest, this, _1, _2),
- bind(&WriteHandle::onRegisterFailed, this, _1, _2));
+ getFace().setInterestFilter(Name(prefix).append("insert"),
+ bind(&WriteHandle::onInterest, this, _1, _2));
+ getFace().setInterestFilter(Name(prefix).append("insert check"),
+ bind(&WriteHandle::onCheckInterest, this, _1, _2));
}
void