Remove use of deprecated code
Change-Id: Iad490b91ca7e28cbbfbf02a4c83ad6a9223354d4
Refs: #3988
diff --git a/src/leaf-container.hpp b/src/leaf-container.hpp
index 51470b7..d116b55 100644
--- a/src/leaf-container.hpp
+++ b/src/leaf-container.hpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -47,7 +47,7 @@
operator()(const Name& prefix) const
{
ndn::ConstBufferPtr buffer =
- ndn::crypto::sha256(prefix.wireEncode().wire(), prefix.wireEncode().size());
+ ndn::crypto::computeSha256Digest(prefix.wireEncode().wire(), prefix.wireEncode().size());
BOOST_ASSERT(buffer->size() > sizeof(std::size_t));
diff --git a/src/logic.cpp b/src/logic.cpp
index 278115e..4caa56e 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -52,7 +52,7 @@
const ndn::Name Logic::DEFAULT_NAME;
const ndn::Name Logic::EMPTY_NAME;
-const ndn::shared_ptr<ndn::Validator> Logic::DEFAULT_VALIDATOR;
+const std::shared_ptr<ndn::Validator> Logic::DEFAULT_VALIDATOR;
const time::steady_clock::Duration Logic::DEFAULT_RESET_TIMER = time::seconds(0);
const time::steady_clock::Duration Logic::DEFAULT_CANCEL_RESET_TIMER = time::milliseconds(500);
const time::milliseconds Logic::DEFAULT_RESET_INTEREST_LIFETIME(1000);
@@ -69,7 +69,7 @@
const Name& defaultUserPrefix,
const UpdateCallback& onUpdate,
const Name& defaultSigningId,
- ndn::shared_ptr<ndn::Validator> validator,
+ std::shared_ptr<ndn::Validator> validator,
const time::steady_clock::Duration& resetTimer,
const time::steady_clock::Duration& cancelResetTimer,
const time::milliseconds& resetInterestLifetime,
@@ -213,7 +213,7 @@
if (node != m_nodeList.end())
return node->second.sessionName;
else
- throw Error("Refer to non-existent node:" + prefix.toUri());
+ BOOST_THROW_EXCEPTION(Error("Refer to non-existent node:" + prefix.toUri()));
}
const SeqNo&
@@ -225,12 +225,12 @@
if (node != m_nodeList.end())
return node->second.seqNo;
else
- throw Logic::Error("Refer to non-existent node:" + prefix.toUri());
+ BOOST_THROW_EXCEPTION(Logic::Error("Refer to non-existent node:" + prefix.toUri()));
}
void
-Logic::updateSeqNo(const SeqNo& seqNo, const Name &updatePrefix)
+Logic::updateSeqNo(const SeqNo& seqNo, const Name& updatePrefix)
{
Name prefix;
if (updatePrefix == EMPTY_NAME) {
@@ -342,7 +342,7 @@
}
void
-Logic::onSyncData(const Interest& interest, Data& data)
+Logic::onSyncData(const Interest& interest, const Data& data)
{
_LOG_DEBUG_ID(">> Logic::onSyncData");
// if (static_cast<bool>(m_validator))
@@ -366,7 +366,7 @@
}
void
-Logic::onResetData(const Interest& interest, Data& data)
+Logic::onResetData(const Interest& interest, const Data& data)
{
// This should not happened, drop the received data.
}
@@ -531,7 +531,7 @@
_LOG_DEBUG_ID("What? nothing new");
}
}
- catch (State::Error&) {
+ catch (const State::Error&) {
_LOG_DEBUG_ID("Something really fishy happened during state decoding");
// Something really fishy happened during state decoding;
commit.reset();
@@ -566,7 +566,7 @@
}
m_interestTable.clear();
}
- catch (InterestTable::Error&) {
+ catch (const InterestTable::Error&) {
// ok. not really an error
}
_LOG_DEBUG_ID("<< Logic::satisfyPendingSyncInterests");
@@ -607,6 +607,7 @@
interest.setInterestLifetime(m_resetInterestLifetime);
m_face.expressInterest(interest,
bind(&Logic::onResetData, this, _1, _2),
+ bind(&Logic::onSyncTimeout, this, _1), // Nack
bind(&Logic::onSyncTimeout, this, _1));
_LOG_DEBUG_ID("<< Logic::sendResetInterest");
@@ -640,6 +641,7 @@
m_outstandingInterestId = m_face.expressInterest(interest,
bind(&Logic::onSyncData, this, _1, _2),
+ bind(&Logic::onSyncTimeout, this, _1), // Nack
bind(&Logic::onSyncTimeout, this, _1));
_LOG_DEBUG_ID("Send interest: " << interest.getName());
@@ -720,8 +722,10 @@
interest.setMustBeFresh(true);
interest.setInterestLifetime(m_recoveryInterestLifetime);
- m_face.expressInterest(interest, bind(&Logic::onRecoveryData, this, _1, _2),
- bind(&Logic::onRecoveryTimeout, this, _1));
+ m_face.expressInterest(interest,
+ bind(&Logic::onRecoveryData, this, _1, _2),
+ bind(&Logic::onRecoveryTimeout, this, _1), // Nack
+ bind(&Logic::onRecoveryTimeout, this, _1));
_LOG_DEBUG_ID("interest: " << interest.getName());
_LOG_DEBUG_ID("<< Logic::sendRecoveryInterest");
@@ -748,7 +752,7 @@
}
void
-Logic::onRecoveryData(const Interest& interest, Data& data)
+Logic::onRecoveryData(const Interest& interest, const Data& data)
{
_LOG_DEBUG_ID(">> Logic::onRecoveryData");
onSyncDataValidated(data.shared_from_this());
@@ -777,8 +781,10 @@
excludeInterest.setInterestLifetime(m_syncInterestLifetime);
- m_face.expressInterest(excludeInterest, bind(&Logic::onSyncData, this, _1, _2),
- bind(&Logic::onSyncTimeout, this, _1));
+ m_face.expressInterest(excludeInterest,
+ bind(&Logic::onSyncData, this, _1, _2),
+ bind(&Logic::onSyncTimeout, this, _1), // Nack
+ bind(&Logic::onSyncTimeout, this, _1));
_LOG_DEBUG_ID("Send interest: " << excludeInterest.getName());
_LOG_DEBUG_ID("<< Logic::sendExcludeInterest");
@@ -808,4 +814,4 @@
_LOG_DEBUG_ID("<< Logic::formAndSendExcludeInterest");
}
-} // namespace chronosync
\ No newline at end of file
+} // namespace chronosync
diff --git a/src/logic.hpp b/src/logic.hpp
index c452d20..b07ba62 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -121,7 +121,7 @@
const Name& defaultUserPrefix,
const UpdateCallback& onUpdate,
const Name& defaultSigningId = DEFAULT_NAME,
- ndn::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR,
+ std::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR,
const time::steady_clock::Duration& resetTimer = DEFAULT_RESET_TIMER,
const time::steady_clock::Duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
@@ -264,7 +264,7 @@
* @param data The reply to the Sync Interest
*/
void
- onSyncData(const Interest& interest, Data& data);
+ onSyncData(const Interest& interest, const Data& data);
/**
* @brief Callback to handle reply to Reset Interest.
@@ -275,7 +275,7 @@
* @param data The reply to the Reset Interest
*/
void
- onResetData(const Interest& interest, Data& data);
+ onResetData(const Interest& interest, const Data& data);
/**
* @brief Callback to handle Sync Interest timeout.
@@ -423,7 +423,7 @@
* @param data The reply to the Recovery Interest
*/
void
- onRecoveryData(const Interest& interest, Data& data);
+ onRecoveryData(const Interest& interest, const Data& data);
/**
* @brief Callback to handle Recovery Interest timeout.
@@ -461,7 +461,7 @@
public:
static const ndn::Name DEFAULT_NAME;
static const ndn::Name EMPTY_NAME;
- static const ndn::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
+ static const std::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
private:
typedef std::unordered_map<ndn::Name, NodeInfo> NodeList;
@@ -516,7 +516,7 @@
// Security
ndn::Name m_defaultSigningId;
ndn::KeyChain m_keyChain;
- ndn::shared_ptr<ndn::Validator> m_validator;
+ std::shared_ptr<ndn::Validator> m_validator;
#ifdef _DEBUG
@@ -528,4 +528,4 @@
} // namespace chronosync
-#endif // CHRONOSYNC_LOGIC_HPP
\ No newline at end of file
+#endif // CHRONOSYNC_LOGIC_HPP
diff --git a/src/socket.cpp b/src/socket.cpp
index 4d46d7f..dad1125 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -32,14 +32,14 @@
const ndn::Name Socket::DEFAULT_NAME;
const ndn::Name Socket::DEFAULT_PREFIX;
-const ndn::shared_ptr<ndn::Validator> Socket::DEFAULT_VALIDATOR;
+const std::shared_ptr<ndn::Validator> Socket::DEFAULT_VALIDATOR;
Socket::Socket(const Name& syncPrefix,
const Name& userPrefix,
ndn::Face& face,
const UpdateCallback& updateCallback,
const Name& signingId,
- ndn::shared_ptr<ndn::Validator> validator)
+ std::shared_ptr<ndn::Validator> validator)
: m_userPrefix(userPrefix)
, m_face(face)
, m_logic(face, syncPrefix, userPrefix, updateCallback)
@@ -146,6 +146,8 @@
m_face.expressInterest(interest,
bind(&Socket::onData, this, _1, _2, dataCallback, failureCallback),
bind(&Socket::onDataTimeout, this, _1, nRetries,
+ dataCallback, failureCallback), // Nack
+ bind(&Socket::onDataTimeout, this, _1, nRetries,
dataCallback, failureCallback));
}
@@ -153,7 +155,7 @@
Socket::fetchData(const Name& sessionName, const SeqNo& seqNo,
const ndn::OnDataValidated& dataCallback,
const ndn::OnDataValidationFailed& failureCallback,
- const ndn::OnTimeout& onTimeout,
+ const ndn::TimeoutCallback& onTimeout,
int nRetries)
{
_LOG_DEBUG(">> Socket::fetchData");
@@ -165,6 +167,7 @@
m_face.expressInterest(interest,
bind(&Socket::onData, this, _1, _2, dataCallback, failureCallback),
+ bind(onTimeout, _1), // Nack
onTimeout);
_LOG_DEBUG("<< Socket::fetchData");
@@ -180,7 +183,7 @@
}
void
-Socket::onData(const Interest& interest, Data& data,
+Socket::onData(const Interest& interest, const Data& data,
const ndn::OnDataValidated& onValidated,
const ndn::OnDataValidationFailed& onFailed)
{
@@ -204,6 +207,8 @@
m_face.expressInterest(interest,
bind(&Socket::onData, this, _1, _2, onValidated, onFailed),
bind(&Socket::onDataTimeout, this, _1, nRetries - 1,
+ onValidated, onFailed), // Nack
+ bind(&Socket::onDataTimeout, this, _1, nRetries - 1,
onValidated, onFailed));
}
diff --git a/src/socket.hpp b/src/socket.hpp
index d213018..807e173 100644
--- a/src/socket.hpp
+++ b/src/socket.hpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -64,7 +64,7 @@
ndn::Face& face,
const UpdateCallback& updateCallback,
const Name& signingId = DEFAULT_NAME,
- ndn::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR);
+ std::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR);
~Socket();
@@ -151,7 +151,7 @@
fetchData(const Name& sessionName, const SeqNo& seq,
const ndn::OnDataValidated& onValidated,
const ndn::OnDataValidationFailed& onValidationFailed,
- const ndn::OnTimeout& onTimeout,
+ const ndn::TimeoutCallback& onTimeout,
int nRetries = 0);
/// @brief Get the root digest of current sync tree
@@ -169,7 +169,7 @@
onInterest(const Name& prefix, const Interest& interest);
void
- onData(const Interest& interest, Data& data,
+ onData(const Interest& interest, const Data& data,
const ndn::OnDataValidated& dataCallback,
const ndn::OnDataValidationFailed& failCallback);
@@ -185,7 +185,7 @@
public:
static const ndn::Name DEFAULT_NAME;
static const ndn::Name DEFAULT_PREFIX;
- static const ndn::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
+ static const std::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
private:
typedef std::unordered_map<ndn::Name, const ndn::RegisteredPrefixId*> RegisteredPrefixList;
@@ -196,7 +196,7 @@
ndn::Name m_signingId;
ndn::KeyChain m_keyChain;
- ndn::shared_ptr<ndn::Validator> m_validator;
+ std::shared_ptr<ndn::Validator> m_validator;
RegisteredPrefixList m_registeredPrefixList;
ndn::util::InMemoryStoragePersistent m_ims;
diff --git a/src/state.cpp b/src/state.cpp
index 251d46b..0b2c0c7 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -143,11 +143,11 @@
State::wireDecode(const Block& wire)
{
if (!wire.hasWire())
- throw Error("The supplied block does not contain wire format");
+ BOOST_THROW_EXCEPTION(Error("The supplied block does not contain wire format"));
if (wire.type() != tlv::SyncReply)
- throw Error("Unexpected TLV type when decoding SyncReply: " +
- boost::lexical_cast<std::string>(m_wire.type()));
+ BOOST_THROW_EXCEPTION(Error("Unexpected TLV type when decoding SyncReply: " +
+ boost::lexical_cast<std::string>(m_wire.type())));
wire.parse();
m_wire = wire;
@@ -164,7 +164,7 @@
if (val != it->elements_end())
update(info, readNonNegativeInteger(*val));
else
- throw Error("No seqNo when decoding SyncReply");
+ BOOST_THROW_EXCEPTION(Error("No seqNo when decoding SyncReply"));
}
}
}
diff --git a/tests/unit-tests/test-interest-table.cpp b/tests/unit-tests/test-interest-table.cpp
index 531de09..8b1f156 100644
--- a/tests/unit-tests/test-interest-table.cpp
+++ b/tests/unit-tests/test-interest-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -36,19 +36,19 @@
Name prefix("/test/prefix");
Name interestName1;
- digest1 = ndn::crypto::sha256(origin, 1);
+ digest1 = ndn::crypto::computeSha256Digest(origin, 1);
interestName1.append(prefix).append(name::Component(digest1));
interest1 = make_shared<Interest>(interestName1);
interest1->setInterestLifetime(time::milliseconds(100));
Name interestName2;
- digest2 = ndn::crypto::sha256(origin, 2);
+ digest2 = ndn::crypto::computeSha256Digest(origin, 2);
interestName2.append(prefix).append(name::Component(digest2));
interest2 = make_shared<Interest>(interestName2);
interest2->setInterestLifetime(time::milliseconds(100));
Name interestName3;
- digest3 = ndn::crypto::sha256(origin, 3);
+ digest3 = ndn::crypto::computeSha256Digest(origin, 3);
interestName3.append(prefix).append(name::Component(digest3));
interest3 = make_shared<Interest>(interestName3);
interest3->setInterestLifetime(time::milliseconds(100));
@@ -121,16 +121,16 @@
{
InterestTable table(io);
- insert(ndn::ref(table), interest1, digest1);
+ insert(table, interest1, digest1);
advanceClocks(ndn::time::milliseconds(10), 10);
- insert(ndn::ref(table), interest2, digest2);
- insert(ndn::ref(table), interest3, digest3);
+ insert(table, interest2, digest2);
+ insert(table, interest3, digest3);
advanceClocks(ndn::time::milliseconds(10), 5);
- insert(ndn::ref(table), interest2, digest2);
+ insert(table, interest2, digest2);
advanceClocks(ndn::time::milliseconds(10), 2);
BOOST_CHECK_EQUAL(table.size(), 2);