Avoid deprecated ndn-cxx functions
Also, waf is updated to version 2.0.23
Change-Id: I053d7dce733455ec352931a1614082542ca00570
diff --git a/src/leaf-container.hpp b/src/leaf-container.hpp
index 4e7a805..0a01bd7 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-2021 University of California, Los Angeles
+ * Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -42,14 +42,12 @@
struct SessionNameHash
{
+ static_assert(ndn::util::Sha256::DIGEST_SIZE >= sizeof(std::size_t), "");
+
std::size_t
operator()(const Name& prefix) const
{
- ConstBufferPtr buffer =
- ndn::util::Sha256::computeDigest(prefix.wireEncode().wire(), prefix.wireEncode().size());
-
- BOOST_ASSERT(buffer->size() > sizeof(std::size_t));
-
+ auto buffer = ndn::util::Sha256::computeDigest(prefix.wireEncode());
return *reinterpret_cast<const std::size_t*>(buffer->data());
}
};
diff --git a/src/logic.cpp b/src/logic.cpp
index 9d09bbc..05defbd 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -273,10 +273,7 @@
if (!m_isInReset) {
CHRONO_LOG_DBG("updateSeqNo: not in Reset");
ConstBufferPtr previousRoot = m_state.getRootDigest();
- {
- std::string hash = ndn::toHex(previousRoot->data(), previousRoot->size(), false);
- CHRONO_LOG_DBG("Hash: " << hash);
- }
+ printDigest(previousRoot);
bool isInserted = false;
bool isUpdated = false;
@@ -398,7 +395,7 @@
void
Logic::onSyncDataValidated(const Data& data)
{
- Name name = data.getName();
+ const auto& name = data.getName();
ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
try {
@@ -407,7 +404,7 @@
processSyncData(name, digest, Block(std::move(contentBuffer)));
}
catch (const std::ios_base::failure& error) {
- NDN_LOG_WARN("Error decompressing content of " << data.getName() << " (" << error.what() << ")");
+ NDN_LOG_WARN("Error decompressing content of " << name << " (" << error.what() << ")");
}
}
@@ -416,9 +413,8 @@
{
CHRONO_LOG_DBG(">> Logic::processSyncInterest");
- Name name = interest.getName();
+ const auto& name = interest.getName();
ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
-
ConstBufferPtr rootDigest = m_state.getRootDigest();
// If the digest of the incoming interest is the same as root digest
@@ -669,7 +665,7 @@
syncReply.setFreshnessPeriod(m_syncReplyFreshness);
auto finalizeReply = [this, &nodePrefix, &syncReply] (const State& state) {
- auto contentBuffer = bzip2::compress(reinterpret_cast<const char*>(state.wireEncode().wire()),
+ auto contentBuffer = bzip2::compress(reinterpret_cast<const char*>(state.wireEncode().data()),
state.wireEncode().size());
syncReply.setContent(contentBuffer);
@@ -737,10 +733,9 @@
}
void
-Logic::printDigest(ConstBufferPtr digest)
+Logic::printDigest(const ConstBufferPtr& digest) const
{
- std::string hash = ndn::toHex(digest->data(), digest->size(), false);
- CHRONO_LOG_DBG("Hash: " << hash);
+ CHRONO_LOG_DBG("Hash: " << ndn::toHex(*digest, false));
}
void
@@ -771,7 +766,7 @@
{
CHRONO_LOG_DBG(">> Logic::processRecoveryInterest");
- Name name = interest.getName();
+ const auto& name = interest.getName();
ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
ConstBufferPtr rootDigest = m_state.getRootDigest();
diff --git a/src/logic.hpp b/src/logic.hpp
index 25514ed..1383ef2 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2021 University of California, Los Angeles
+ * Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -399,7 +399,7 @@
cancelReset();
void
- printDigest(ConstBufferPtr digest);
+ printDigest(const ConstBufferPtr& digest) const;
/**
* @brief Helper method to send Recovery Interest
diff --git a/src/socket.cpp b/src/socket.cpp
index 346e968..e2c8b66 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -55,8 +55,8 @@
if (m_userPrefix != DEFAULT_NAME)
m_registeredPrefixList[m_userPrefix] =
m_face.setInterestFilter(m_userPrefix,
- bind(&Socket::onInterest, this, _1, _2),
- [] (const Name&, const std::string&) {});
+ [this] (auto&&... args) { onInterest(std::forward<decltype(args)>(args)...); },
+ [] (auto&&...) {});
NDN_LOG_DEBUG("<< Socket::Socket");
}
@@ -84,8 +84,8 @@
m_logic.addUserNode(prefix, signingId, session);
m_registeredPrefixList[prefix] =
m_face.setInterestFilter(prefix,
- bind(&Socket::onInterest, this, _1, _2),
- [] (const Name&, const std::string&) {});
+ [this] (auto&&... args) { onInterest(std::forward<decltype(args)>(args)...); },
+ [] (auto&&...) {});
NDN_LOG_DEBUG("<< addSyncNode");
}
@@ -110,14 +110,14 @@
Socket::publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness,
const Name& prefix)
{
- publishData(ndn::encoding::makeBinaryBlock(ndn::tlv::Content, buf, len), freshness, prefix);
+ publishData(ndn::makeBinaryBlock(ndn::tlv::Content, {buf, len}), freshness, prefix);
}
void
Socket::publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness,
const uint64_t& seqNo, const Name& prefix)
{
- publishData(ndn::encoding::makeBinaryBlock(ndn::tlv::Content, buf, len), freshness, seqNo, prefix);
+ publishData(ndn::makeBinaryBlock(ndn::tlv::Content, {buf, len}), freshness, seqNo, prefix);
}
void
@@ -178,7 +178,7 @@
interest.setMustBeFresh(true);
DataValidationErrorCallback failureCallback =
- bind(&Socket::onDataValidationFailed, this, _1, _2);
+ [this] (auto&&... args) { onDataValidationFailed(std::forward<decltype(args)>(args)...); };
m_face.expressInterest(interest,
bind(&Socket::onData, this, _1, _2, dataCallback, failureCallback),
@@ -254,8 +254,7 @@
}
void
-Socket::onDataValidationFailed(const Data& data,
- const ValidationError& error)
+Socket::onDataValidationFailed(const Data&, const ValidationError&)
{
}
diff --git a/src/state.cpp b/src/state.cpp
index ab9d87d..00df7b9 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-2021 University of California, Los Angeles
+ * Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -48,7 +48,7 @@
}
SeqNo old = (*leaf)->getSeq();
- m_leaves.modify(leaf, [=] (LeafPtr& leaf) { leaf->setSeq(seq); } );
+ m_leaves.modify(leaf, [seq] (LeafPtr& leaf) { leaf->setSeq(seq); } );
return std::make_tuple(false, true, old);
}
}
@@ -60,7 +60,7 @@
for (const auto& leaf : m_leaves.get<ordered>()) {
BOOST_ASSERT(leaf != nullptr);
- m_digest.update(leaf->getDigest()->data(), leaf->getDigest()->size());
+ m_digest.update(*leaf->getDigest());
}
return m_digest.computeDigest();