Skip to content

Conversation

@matianxing1992
Copy link

A new API to publish names only (Won't change old APIs);
Subscribe with Regex and users can decide whether fetching data automatically;

#include <ndn-cxx/face.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/util/regex.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include this in the files where it's actually needed, not in common.hpp

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review and I will update them accordingly

SubscriptionCallback callback;
bool isPacketSubscription;
bool prefetch;
std::shared_ptr<Regex> regex = make_shared<Regex>("^<>+$");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a shared_ptr?

Comment on lines 101 to 108
NodeID nid = nodePrefix == EMPTY_NAME ? m_dataPrefix : nodePrefix;
SeqNo seqNo = m_svsync.getCore().getSeqNo(nid) + 1;

// Insert mapping and manually update the sequence number
insertMapping(nid, seqNo, name, mappingBlocks);
m_svsync.getCore().updateSeqNo(seqNo, nid);

return seqNo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation looks wrong

for (const auto& sub : m_prefixSubscriptions)
{
if (sub.prefix.isPrefixOf(mapping.first))
if (sub.prefix.isPrefixOf(mapping.first) and sub.autofetch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use && in C++

m_fetchMap[std::pair(nodeId, seqNo)].push_back(sub);
queued = true;
}
else if (sub.prefix.isPrefixOf(mapping.first) and !sub.autofetch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor the if/else to avoid repeating the conditions

ndn::span<const uint8_t>{},
nodeId,
seqNo,
ndn::Data()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this "passing an empty Data" to be honest...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any suggestion? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment... I didn't do too much thinking to be honest. But maybe this should be a new/separate API instead of shoehorning it into the existing API with a bool as discriminator.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... But it's better to be compatible with old APIs because of existing apps...

bool isPacketSubscription;
bool prefetch;
std::shared_ptr<Regex> regex = make_shared<Regex>("^<>+$");
bool autofetch = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wastes space in the struct, please move the bool next to the others above to minimize padding. Even better, the bools and the uint32_t should be grouped together.

for (const auto& sub : m_regexSubscriptions)
{
if (sub.regex->match(mapping.first))
if (sub.regex->match(mapping.first) and sub.autofetch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...&&...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants