lokinet/llarp/dht/publishservicejob.cpp

48 lines
1.3 KiB
C++
Raw Normal View History

2019-01-22 01:14:02 +00:00
#include <dht/publishservicejob.hpp>
#include <dht/context.hpp>
#include <dht/messages/pubintro.hpp>
2019-07-30 23:42:13 +00:00
#include <utility>
2019-01-22 01:14:02 +00:00
namespace llarp
{
namespace dht
{
PublishServiceJob::PublishServiceJob(const TXOwner &asker,
const service::IntroSet &introset,
AbstractContext *ctx, uint64_t s,
2019-07-30 23:42:13 +00:00
std::set< Key_t > exclude)
2019-01-22 01:14:02 +00:00
: TX< service::Address, service::IntroSet >(asker, introset.A.Addr(),
ctx)
, S(s)
2019-07-30 23:42:13 +00:00
, dontTell(std::move(exclude))
2019-01-22 01:14:02 +00:00
, I(introset)
{
}
bool
PublishServiceJob::Validate(const service::IntroSet &introset) const
{
if(I.A != introset.A)
{
llarp::LogWarn(
"publish introset acknowledgement acked a different service");
return false;
}
return true;
}
void
PublishServiceJob::Start(const TXOwner &peer)
{
std::vector< Key_t > exclude;
for(const auto &router : dontTell)
{
exclude.push_back(router);
}
parent->DHTSendTo(peer.node.as_array(),
new PublishIntroMessage(I, peer.txid, S, exclude));
}
} // namespace dht
} // namespace llarp