Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix! obsolete ndn function calls on kua #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
"variant": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__locale": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp",
"charconv": "cpp",
"execution": "cpp",
"ios": "cpp",
"locale": "cpp",
"queue": "cpp",
"*.ipp": "cpp",
"format": "cpp"
}
}
2 changes: 1 addition & 1 deletion src/auction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AuctionMessage::wireEncode() const
}

#define K_ENCODE_BLK(VAR_V, TLV_V) {\
size_t valLength = enc.prependBlock(VAR_V); \
size_t valLength = enc.prependBytes(VAR_V); \
totalLength += enc.prependVarNumber(valLength); \
totalLength += enc.prependVarNumber(TLV_V); \
totalLength += valLength; \
Expand Down
10 changes: 6 additions & 4 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <iostream>
#include <chrono>
#include<span>

#include "config-bundle.hpp"
#include "bucket.hpp"
Expand Down Expand Up @@ -98,7 +99,7 @@ class Client
ndn::Interest interest(interestName);
interest.setMustBeFresh(false);
interest.setCanBePrefix(false);
interest.setForwardingHint(ndn::DelegationList({{15893, hint }}));
interest.setForwardingHint(std::vector<ndn::Name> {15893, hint});

m_face.expressInterest(interest,
[this, interestName] (const ndn::Interest&, const ndn::Data& data) {
Expand Down Expand Up @@ -244,11 +245,12 @@ class Client
while (is.good()) {
is.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
const auto nCharsRead = is.gcount();
ndn::span<uint8_t> bufferSpan(buffer);

if (nCharsRead > 0) {
auto data = std::make_shared<ndn::Data>(ndn::Name(name).appendSegment(m_store.size()));
data->setFreshnessPeriod(ndn::time::seconds(10));
data->setContent(buffer.data(), static_cast<size_t>(nCharsRead));
data->setContent(bufferSpan);
m_store.push_back(data);
}
}
Expand Down Expand Up @@ -298,8 +300,8 @@ class Client
unsigned int pointer = 0;
unsigned int done = 0;

std::chrono::_V2::system_clock::time_point start_time;
std::chrono::_V2::system_clock::time_point end_time;
std::chrono::high_resolution_clock::time_point start_time;
std::chrono::high_resolution_clock::time_point end_time;
};

} // namespace kua
Expand Down
2 changes: 1 addition & 1 deletion src/node-watcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NodeWatcher
ndn::random::RandomNumberEngine& m_rng;
std::uniform_int_distribution<> m_retxDist;

std::map<ndn::Name, std::chrono::_V2::system_clock::time_point> m_nodeMap;
std::map<ndn::Name, std::chrono::system_clock::time_point> m_nodeMap;

std::unique_ptr<ndn::svs::SVSync> m_svs;
};
Expand Down
12 changes: 8 additions & 4 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Worker::Worker(ConfigBundle& configBundle, const Bucket& bucket)
: m_configBundle(configBundle)
, m_bucket(bucket)
, m_nodePrefix(configBundle.nodePrefix)
, m_scheduler(m_face.getIoService())
, m_scheduler(m_face.getIoContext())
, m_keyChain(configBundle.keyChain)
, m_bucketPrefix(ndn::Name(configBundle.kuaPrefix).appendNumber(bucket.id))
, m_bucketNodePrefix(ndn::Name(m_nodePrefix).appendNumber(bucket.id))
Expand Down Expand Up @@ -105,10 +105,14 @@ Worker::onInterest(const ndn::InterestFilter&, const ndn::Interest& interest)
}

// FETCH command
for (const auto& delegation : interest.getForwardingHint())
if (delegation.name.size() > 1 && delegation.name[-1].isNumber() &&
delegation.name[-1].toNumber() == CommandCodes::FETCH)

for (size_t i = 0; i < interest.getForwardingHint().size(); ++i) {
const ndn::Name& delegation = interest.getForwardingHint()[i];
if (delegation.size() > 1 && delegation[-1].isNumber() &&
delegation[-1].toNumber() == CommandCodes::FETCH) {
return this->fetch(interest);
}
}
}

void
Expand Down