mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-02 03:40:12 +00:00
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <dht/publishservicejob.hpp>
|
|
|
|
#include <dht/context.hpp>
|
|
#include <dht/messages/pubintro.hpp>
|
|
#include <dht/messages/gotintro.hpp>
|
|
#include <utility>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace dht
|
|
{
|
|
PublishServiceJob::PublishServiceJob(
|
|
const TXOwner &asker, const service::EncryptedIntroSet &introset_,
|
|
AbstractContext *ctx, bool relayed_, uint64_t relayOrder_)
|
|
: TX< TXOwner, service::EncryptedIntroSet >(asker, asker, ctx)
|
|
, relayed(relayed_)
|
|
, relayOrder(relayOrder_)
|
|
, introset(introset_)
|
|
{
|
|
}
|
|
|
|
bool
|
|
PublishServiceJob::Validate(const service::EncryptedIntroSet &value) const
|
|
{
|
|
if(value.derivedSigningKey != introset.derivedSigningKey)
|
|
{
|
|
llarp::LogWarn(
|
|
"publish introset acknowledgement acked a different service");
|
|
return false;
|
|
}
|
|
const llarp_time_t now = llarp::time_now_ms();
|
|
return value.Verify(now);
|
|
}
|
|
|
|
void
|
|
PublishServiceJob::Start(const TXOwner &peer)
|
|
{
|
|
parent->DHTSendTo(
|
|
peer.node.as_array(),
|
|
new PublishIntroMessage(introset, peer.txid, relayed, relayOrder));
|
|
}
|
|
|
|
void
|
|
PublishServiceJob::SendReply()
|
|
{
|
|
parent->DHTSendTo(whoasked.node.as_array(),
|
|
new GotIntroMessage({introset}, whoasked.txid));
|
|
}
|
|
|
|
} // namespace dht
|
|
} // namespace llarp
|