logic: use properly seeded rng via ndn::random::getRandomNumberEngine
Change-Id: I2a3a84b62ef9b21857097ce6a56fed92f8ddea86
diff --git a/.waf-tools/boost.py b/.waf-tools/boost.py
index bb65d7c..d7e0107 100644
--- a/.waf-tools/boost.py
+++ b/.waf-tools/boost.py
@@ -405,8 +405,8 @@
self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
if self.env.DPKG_ARCHITECTURE:
- deb_host_multiarch = Utils.subprocess.check_output([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH']).strip()
- BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch)
+ deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
+ BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
self.start_msg('Checking boost includes')
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
diff --git a/src/logic.cpp b/src/logic.cpp
index 35480ee..7bf4428 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2018 University of California, Los Angeles
+ * Copyright (c) 2012-2019 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -121,7 +121,7 @@
, m_needPeriodReset(resetTimer > time::steady_clock::Duration::zero())
, m_onUpdate(onUpdate)
, m_scheduler(m_face.getIoService())
- , m_rng(std::random_device{}())
+ , m_rng(ndn::random::getRandomNumberEngine())
, m_rangeUniformRandom(100, 500)
, m_reexpressionJitter(100, 500)
, m_resetTimer(resetTimer)
@@ -866,56 +866,4 @@
}
}
-// void
-// Logic::sendExcludeInterest(const Interest& interest, const Data& data)
-// {
-// _LOG_DEBUG_ID(">> Logic::sendExcludeInterest");
-
-// Name interestName = interest.getName();
-// Interest excludeInterest(interestName);
-
-// Exclude exclude = interest.getExclude();
-// exclude.excludeOne(data.getFullName().get(-1));
-// excludeInterest.setExclude(exclude);
-// excludeInterest.setMustBeFresh(true);
-
-// excludeInterest.setInterestLifetime(m_syncInterestLifetime);
-
-// if (excludeInterest.wireEncode().size() > ndn::MAX_NDN_PACKET_SIZE) {
-// return;
-// }
-
-// 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");
-// }
-
-// void
-// Logic::formAndSendExcludeInterest(const Name& nodePrefix, const State& commit, ConstBufferPtr previousRoot)
-// {
-// _LOG_DEBUG_ID(">> Logic::formAndSendExcludeInterest");
-// Name interestName;
-// interestName.append(m_syncPrefix)
-// .append(ndn::name::Component(*previousRoot));
-// Interest interest(interestName);
-
-// Data data(interestName);
-// data.setContent(commit.wireEncode());
-// data.setFreshnessPeriod(m_syncReplyFreshness);
-// if (m_nodeList.find(nodePrefix) == m_nodeList.end())
-// return;
-// if (m_nodeList[nodePrefix].signingId.empty())
-// m_keyChain.sign(data);
-// else
-// m_keyChain.sign(data, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
-
-// sendExcludeInterest(interest, data);
-
-// _LOG_DEBUG_ID("<< Logic::formAndSendExcludeInterest");
-// }
-
} // namespace chronosync
diff --git a/src/logic.hpp b/src/logic.hpp
index a71080f..b92ec38 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-2018 University of California, Los Angeles
+ * Copyright (c) 2012-2019 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -29,6 +29,8 @@
#include "diff-state-container.hpp"
#include "interest-table.hpp"
+#include <ndn-cxx/util/random.hpp>
+
#include <boost/archive/iterators/dataflow_exception.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/assert.hpp>
@@ -36,7 +38,6 @@
#include <boost/throw_exception.hpp>
#include <memory>
-#include <random>
#include <unordered_map>
namespace chronosync {
@@ -509,7 +510,7 @@
ndn::EventId m_resetInterestId;
// Timer
- std::mt19937 m_rng;
+ ndn::random::RandomNumberEngine& m_rng;
std::uniform_int_distribution<> m_rangeUniformRandom;
std::uniform_int_distribution<> m_reexpressionJitter;
/// @brief Timer to send next reset 0 for no reset