lokinet/llarp/dht/taglookup.cpp

41 lines
951 B
C++
Raw Normal View History

2019-01-22 01:14:02 +00:00
#include <dht/taglookup.hpp>
#include <dht/context.hpp>
#include <dht/messages/gotintro.hpp>
namespace llarp
{
namespace dht
{
bool
TagLookup::Validate(const service::EncryptedIntroSet& introset) const
2019-01-22 01:14:02 +00:00
{
if (!introset.Verify(parent->Now()))
2019-01-22 01:14:02 +00:00
{
llarp::LogWarn("got invalid introset from tag lookup");
return false;
}
if (not introset.topic.has_value())
2020-01-27 21:30:41 +00:00
return false;
if (introset.topic.value() != target)
2019-01-22 01:14:02 +00:00
{
llarp::LogWarn("got introset with missmatched topic in tag lookup");
return false;
}
return true;
}
void
TagLookup::Start(const TXOwner& peer)
2019-01-22 01:14:02 +00:00
{
parent->DHTSendTo(peer.node.as_array(), new FindIntroMessage(target, peer.txid));
2019-01-22 01:14:02 +00:00
}
void
TagLookup::SendReply()
{
parent->DHTSendTo(whoasked.node.as_array(), new GotIntroMessage({}, whoasked.txid));
2019-01-22 01:14:02 +00:00
}
} // namespace dht
} // namespace llarp