Skip to content

Commit 8fa2a98

Browse files
committed
full-producer*: fix compilation
Fix some code style issues Change-Id: I718241514bc05516ba18910e57fa6f49e0ad6602
1 parent a9e143d commit 8fa2a98

11 files changed

+401
-54
lines changed

Diff for: PSync/detail/user-prefixes.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
1818
**/
1919

20-
#include <ndn-cxx/util/logger.hpp>
2120
#include "PSync/detail/user-prefixes.hpp"
21+
#include <ndn-cxx/util/logger.hpp>
2222

2323
namespace psync {
2424

@@ -28,7 +28,7 @@ bool
2828
UserPrefixes::addUserNode(const ndn::Name& prefix)
2929
{
3030
if (!isUserNode(prefix)) {
31-
m_prefixes[prefix] = 0;
31+
prefixes[prefix] = 0;
3232
return true;
3333
}
3434
else {
@@ -39,9 +39,9 @@ UserPrefixes::addUserNode(const ndn::Name& prefix)
3939
void
4040
UserPrefixes::removeUserNode(const ndn::Name& prefix)
4141
{
42-
auto it = m_prefixes.find(prefix);
43-
if (it != m_prefixes.end()) {
44-
m_prefixes.erase(it);
42+
auto it = prefixes.find(prefix);
43+
if (it != prefixes.end()) {
44+
prefixes.erase(it);
4545
}
4646
}
4747

@@ -52,12 +52,12 @@ UserPrefixes::updateSeqNo
5252
oldSeqNo = 0;
5353
NDN_LOG_DEBUG("UpdateSeq: " << prefix << " " << seqNo);
5454

55-
auto it = m_prefixes.find(prefix);
56-
if (it != m_prefixes.end()) {
55+
auto it = prefixes.find(prefix);
56+
if (it != prefixes.end()) {
5757
oldSeqNo = it->second;
5858
}
5959
else {
60-
NDN_LOG_WARN("Prefix not found in m_prefixes");
60+
NDN_LOG_WARN("Prefix not found in prefixes");
6161
return false;
6262
}
6363

Diff for: PSync/detail/user-prefixes.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
namespace psync {
2727

2828
/**
29-
* @brief UserPrefixes holds the m_prefixes map from prefix to sequence number,
29+
* @brief UserPrefixes holds the prefixes map from prefix to sequence number,
3030
* used by PartialProducer and FullProducer.
3131
*
3232
* Contains code common to both
@@ -35,15 +35,15 @@ class UserPrefixes
3535
{
3636
public:
3737
/**
38-
* @brief Check if the prefix is in m_prefixes.
38+
* @brief Check if the prefix is in prefixes.
3939
*
4040
* @param prefix The prefix to check.
41-
* @return True if the prefix is in m_prefixes.
41+
* @return True if the prefix is in prefixes.
4242
*/
4343
bool
4444
isUserNode(const ndn::Name& prefix) const
4545
{
46-
return m_prefixes.find(prefix) != m_prefixes.end();
46+
return prefixes.find(prefix) != prefixes.end();
4747
}
4848

4949
/**
@@ -54,8 +54,8 @@ class UserPrefixes
5454
ndn::optional<uint64_t>
5555
getSeqNo(const ndn::Name& prefix) const
5656
{
57-
auto it = m_prefixes.find(prefix);
58-
if (it == m_prefixes.end()) {
57+
auto it = prefixes.find(prefix);
58+
if (it == prefixes.end()) {
5959
return ndn::nullopt;
6060
}
6161
return it->second;
@@ -64,18 +64,18 @@ class UserPrefixes
6464
/**
6565
* @brief Adds a user node for synchronization
6666
*
67-
* Initializes m_prefixes[prefix] to zero
67+
* Initializes prefixes[prefix] to zero
6868
*
6969
* @param prefix the user node to be added
7070
* @return true if the prefix was added, false if the prefix was already in
71-
* m_prefixes.
71+
* prefixes.
7272
*/
7373
bool
7474
addUserNode(const ndn::Name& prefix);
7575

7676
/**
7777
* @brief Remove the user node from synchronization. If the prefix is not in
78-
* m_prefixes, then do nothing.
78+
* prefixes, then do nothing.
7979
*
8080
* The caller should first check isUserNode(prefix) and erase the prefix from
8181
* the IBLT and other maps if needed.
@@ -86,7 +86,7 @@ class UserPrefixes
8686
removeUserNode(const ndn::Name& prefix);
8787

8888
/**
89-
* @brief Update m_prefixes with the given prefix and sequence number. This
89+
* @brief Update prefixes with the given prefix and sequence number. This
9090
* does not update the IBLT. This logs a message for the update.
9191
*
9292
* Whoever calls this needs to make sure that isUserNode(prefix) is true.
@@ -97,15 +97,15 @@ class UserPrefixes
9797
* prefix. If this method returns true and oldSeqNo is not zero, the caller
9898
* can remove the old prefix from the IBLT.
9999
* @return True if the sequence number was updated, false if the prefix was
100-
* not in m_prefixes, or if the seqNo is less than or equal to the old
100+
* not in prefixes, or if the seqNo is less than or equal to the old
101101
* sequence number. If this returns false, the caller should not update the
102102
* IBLT.
103103
*/
104104
bool
105105
updateSeqNo(const ndn::Name& prefix, uint64_t seqNo, uint64_t& oldSeqNo);
106106

107107
// prefix and sequence number
108-
std::map <ndn::Name, uint64_t> m_prefixes;
108+
std::map <ndn::Name, uint64_t> prefixes;
109109
};
110110

111111
} // namespace psync

Diff for: PSync/full-producer-arbitrary.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ FullProducerArbitrary::sendSyncInterest()
102102
m_outstandingInterestName = syncInterestName;
103103

104104
m_scheduledSyncInterestId =
105-
m_scheduler.scheduleEvent(m_syncInterestLifetime / 2 + ndn::time::milliseconds(m_jitter(m_rng)),
106-
[this] { sendSyncInterest(); });
105+
m_scheduler.schedule(m_syncInterestLifetime / 2 + ndn::time::milliseconds(m_jitter(m_rng)),
106+
[this] { sendSyncInterest(); });
107107

108108
ndn::Interest syncInterest(syncInterestName);
109109

@@ -201,7 +201,7 @@ FullProducerArbitrary::onSyncInterest(const ndn::Name& prefixName, const ndn::In
201201
if (m_name2hash.find(name) != m_name2hash.end()) {
202202
if (!m_onShouldAddToSyncDataCallback ||
203203
m_onShouldAddToSyncDataCallback(prefix.toUri(), negative)) {
204-
state.addContent(name);
204+
state.addContent(name);
205205
}
206206
}
207207
}
@@ -216,7 +216,7 @@ FullProducerArbitrary::onSyncInterest(const ndn::Name& prefixName, const ndn::In
216216
}
217217

218218
auto& entry = m_pendingEntries.emplace(interestName, PendingEntryInfoFull{iblt, {}}).first->second;
219-
entry.expirationEvent = m_scheduler.scheduleEvent(interest.getInterestLifetime(),
219+
entry.expirationEvent = m_scheduler.schedule(interest.getInterestLifetime(),
220220
[this, interest] {
221221
NDN_LOG_TRACE("Erase Pending Interest " << interest.getNonce());
222222
m_pendingEntries.erase(interest.getName());

Diff for: PSync/full-producer-arbitrary.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace psync {
4141
struct PendingEntryInfoFull
4242
{
4343
IBLT iblt;
44-
ndn::util::scheduler::ScopedEventId expirationEvent;
44+
ndn::scheduler::ScopedEventId expirationEvent;
4545
};
4646

4747
typedef std::function<void(const std::vector<ndn::Name>&)> ArbitraryUpdateCallback;
@@ -116,7 +116,7 @@ class FullProducerArbitrary : public ProducerBase
116116
void
117117
sendSyncInterest();
118118

119-
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
119+
PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
120120
/**
121121
* @brief Process sync interest from other parties
122122
*
@@ -177,7 +177,7 @@ class FullProducerArbitrary : public ProducerBase
177177
void
178178
satisfyPendingInterests();
179179

180-
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
180+
PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
181181
/**
182182
* @brief Delete pending sync interests that match given name
183183
*/
@@ -189,15 +189,15 @@ class FullProducerArbitrary : public ProducerBase
189189
ndn::KeyChain m_keyChain;
190190
ndn::Scheduler m_scheduler;
191191

192-
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
192+
PSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
193193
SegmentPublisher m_segmentPublisher;
194194

195195
std::map<ndn::Name, PendingEntryInfoFull> m_pendingEntries;
196196
ndn::time::milliseconds m_syncInterestLifetime;
197197
ArbitraryUpdateCallback m_onArbitraryUpdateCallback;
198198
ShouldAddToSyncDataCallback m_onShouldAddToSyncDataCallback;
199199
CanAddName m_onCanAddName;
200-
ndn::util::scheduler::ScopedEventId m_scheduledSyncInterestId;
200+
ndn::scheduler::ScopedEventId m_scheduledSyncInterestId;
201201
std::uniform_int_distribution<> m_jitter;
202202
ndn::Name m_outstandingInterestName;
203203
ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;

Diff for: PSync/full-producer.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ FullProducer::FullProducer(const size_t expectedNumEntries,
5050
ndn::Name prefix = name.getPrefix(-1);
5151
uint64_t seq = name.get(-1).toNumber();
5252

53-
if (m_prefixes.m_prefixes.find(prefix) == m_prefixes.m_prefixes.end() ||
54-
m_prefixes.m_prefixes[prefix] < seq) {
55-
uint64_t oldSeq = m_prefixes.m_prefixes[prefix];
53+
if (m_prefixes.prefixes.find(prefix) == m_prefixes.prefixes.end() ||
54+
m_prefixes.prefixes[prefix] < seq) {
55+
uint64_t oldSeq = m_prefixes.prefixes[prefix];
5656
if (oldSeq != 0) {
5757
m_producerArbitrary.removeName(ndn::Name(prefix).appendNumber(oldSeq));
5858
}
@@ -72,7 +72,7 @@ FullProducer::publishName(const ndn::Name& prefix, ndn::optional<uint64_t> seq)
7272
return;
7373
}
7474

75-
uint64_t newSeq = seq.value_or(m_prefixes.m_prefixes[prefix] + 1);
75+
uint64_t newSeq = seq.value_or(m_prefixes.prefixes[prefix] + 1);
7676

7777
NDN_LOG_INFO("Publish: " << prefix << "/" << newSeq);
7878

@@ -99,7 +99,7 @@ bool
9999
FullProducer::isNotFutureHash(const ndn::Name& prefix, const std::set<uint32_t>& negative)
100100
{
101101
uint32_t nextHash = murmurHash3(N_HASHCHECK,
102-
ndn::Name(prefix).appendNumber(m_prefixes.m_prefixes[prefix] + 1).toUri());
102+
ndn::Name(prefix).appendNumber(m_prefixes.prefixes[prefix] + 1).toUri());
103103
for (const auto& nHash : negative) {
104104
if (nHash == nextHash) {
105105
return false;
@@ -120,8 +120,8 @@ FullProducer::arbitraryUpdateCallBack(const std::vector<ndn::Name>& names)
120120

121121
NDN_LOG_INFO("Updates: " << prefix << " " << seq);
122122

123-
updates.push_back(MissingDataInfo{prefix, m_prefixes.m_prefixes[prefix] + 1, seq});
124-
m_prefixes.m_prefixes[prefix] = seq;
123+
updates.push_back(MissingDataInfo{prefix, m_prefixes.prefixes[prefix] + 1, seq});
124+
m_prefixes.prefixes[prefix] = seq;
125125
}
126126

127127
m_onUpdateCallback(updates);

Diff for: PSync/full-producer.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class FullProducer
112112
removeUserNode(const ndn::Name& prefix)
113113
{
114114
if (m_prefixes.isUserNode(prefix)) {
115-
uint64_t seqNo = m_prefixes.m_prefixes[prefix];
115+
uint64_t seqNo = m_prefixes.prefixes[prefix];
116116
m_prefixes.removeUserNode(prefix);
117117
m_producerArbitrary.removeName(ndn::Name(prefix).appendNumber(seqNo));
118118
}
@@ -142,15 +142,15 @@ class FullProducer
142142
bool
143143
isNotFutureHash(const ndn::Name& prefix, const std::set<uint32_t>& negative);
144144

145-
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
145+
PSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
146146
void
147147
updateSeqNo(const ndn::Name& prefix, uint64_t seq);
148148

149149
private:
150150
void
151151
arbitraryUpdateCallBack(const std::vector<ndn::Name>& names);
152152

153-
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
153+
PSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
154154
FullProducerArbitrary m_producerArbitrary;
155155
UpdateCallback m_onUpdateCallback;
156156

Diff for: PSync/partial-producer.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PartialProducer::publishName(const ndn::Name& prefix, ndn::optional<uint64_t> se
6060
return;
6161
}
6262

63-
uint64_t newSeq = seq.value_or(m_prefixes.m_prefixes[prefix] + 1);
63+
uint64_t newSeq = seq.value_or(m_prefixes.prefixes[prefix] + 1);
6464

6565
NDN_LOG_INFO("Publish: " << prefix << "/" << newSeq);
6666

@@ -102,7 +102,7 @@ PartialProducer::onHelloInterest(const ndn::Name& prefix, const ndn::Interest& i
102102

103103
State state;
104104

105-
for (const auto& prefix : m_prefixes.m_prefixes) {
105+
for (const auto& prefix : m_prefixes.prefixes) {
106106
state.addContent(ndn::Name(prefix.first).appendNumber(prefix.second));
107107
}
108108
NDN_LOG_DEBUG("sending content p: " << state);
@@ -174,7 +174,7 @@ PartialProducer::onSyncInterest(const ndn::Name& prefix, const ndn::Interest& in
174174
std::set<uint32_t> positive;
175175
std::set<uint32_t> negative;
176176

177-
NDN_LOG_TRACE("Number elements in IBF: " << m_prefixes.m_prefixes.size());
177+
NDN_LOG_TRACE("Number elements in IBF: " << m_prefixes.prefixes.size());
178178

179179
bool peel = diff.listEntries(positive, negative);
180180

@@ -197,7 +197,7 @@ PartialProducer::onSyncInterest(const ndn::Name& prefix, const ndn::Interest& in
197197
if (bf.contains(prefix.toUri())) {
198198
// generate data
199199
state.addContent(name);
200-
NDN_LOG_DEBUG("Content: " << prefix << " " << std::to_string(m_prefixes.m_prefixes[prefix]));
200+
NDN_LOG_DEBUG("Content: " << prefix << " " << std::to_string(m_prefixes.prefixes[prefix]));
201201
}
202202
}
203203

@@ -237,7 +237,7 @@ PartialProducer::satisfyPendingSyncInterests(const ndn::Name& prefix) {
237237

238238
NDN_LOG_TRACE("Result of listEntries on the difference: " << peel);
239239

240-
NDN_LOG_TRACE("Number elements in IBF: " << m_prefixes.m_prefixes.size());
240+
NDN_LOG_TRACE("Number elements in IBF: " << m_prefixes.prefixes.size());
241241
NDN_LOG_TRACE("m_threshold: " << m_threshold << " Total: " << positive.size() + negative.size());
242242

243243
if (!peel) {
@@ -249,8 +249,8 @@ PartialProducer::satisfyPendingSyncInterests(const ndn::Name& prefix) {
249249
State state;
250250
if (entry.bf.contains(prefix.toUri()) || positive.size() + negative.size() >= m_threshold) {
251251
if (entry.bf.contains(prefix.toUri())) {
252-
state.addContent(ndn::Name(prefix).appendNumber(m_prefixes.m_prefixes[prefix]));
253-
NDN_LOG_DEBUG("sending sync content " << prefix << " " << std::to_string(m_prefixes.m_prefixes[prefix]));
252+
state.addContent(ndn::Name(prefix).appendNumber(m_prefixes.prefixes[prefix]));
253+
NDN_LOG_DEBUG("sending sync content " << prefix << " " << std::to_string(m_prefixes.prefixes[prefix]));
254254
}
255255
else {
256256
NDN_LOG_DEBUG("Sending with empty content to send latest IBF to consumer");

Diff for: PSync/partial-producer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class PartialProducer : public ProducerBase
113113
removeUserNode(const ndn::Name& prefix)
114114
{
115115
if (m_prefixes.isUserNode(prefix)) {
116-
uint64_t seqNo = m_prefixes.m_prefixes[prefix];
116+
uint64_t seqNo = m_prefixes.prefixes[prefix];
117117
m_prefixes.removeUserNode(prefix);
118118
removeFromIBF(ndn::Name(prefix).appendNumber(seqNo));
119119
}

0 commit comments

Comments
 (0)