dht pub intro message router event thiny doo

pull/1184/head
Jeff Becker 4 years ago committed by Thomas Winget
parent 22ed47ca12
commit e7689b40a7

@ -198,7 +198,9 @@ set(LIB_SRC
service/session.cpp
service/tag_lookup_job.cpp
service/tag.cpp
tooling/router_event.cpp)
tooling/dht_event.cpp
tooling/router_event.cpp
)
if(TRACY_ROOT)
set(LIB_SRC ${LIB_SRC} ${TRACY_ROOT}/TracyClient.cpp)

@ -7,6 +7,8 @@
#include <routing/dht_message.hpp>
#include <nodedb.hpp>
#include <tooling/dht_event.hpp>
namespace llarp
{
namespace dht
@ -57,7 +59,12 @@ namespace llarp
std::vector< std::unique_ptr< IMessage > > &replies) const
{
const auto now = ctx->impl->Now();
const auto keyStr = introset.derivedSigningKey.ToHex();
const llarp::dht::Key_t addr(introset.derivedSigningKey);
const auto keyStr = addr.ToHex();
auto router = ctx->impl->GetRouter();
auto ev = std::make_unique<tooling::PubIntroReceivedEvent>(router->pubkey(), Key_t(relayed ? router->pubkey() : From.data()), addr, txID, relayOrder);
router->NotifyRouterEvent(std::move(ev));
auto &dht = *ctx->impl;
if(!introset.Verify(now))
@ -78,8 +85,6 @@ namespace llarp
return true;
}
const llarp::dht::Key_t addr(introset.derivedSigningKey);
// identify closest 4 routers
auto closestRCs = dht.GetRouter()->nodedb()->FindClosestTo(
addr, IntroSetStorageRedundancy);

@ -0,0 +1,19 @@
#include "dht_event.hpp"
namespace tooling
{
PubIntroReceivedEvent::PubIntroReceivedEvent(const llarp::RouterID & ourRouter, const llarp::dht::Key_t & from, const llarp::dht::Key_t & location, uint64_t txid, uint64_t relayOrder) :
RouterEvent(ourRouter, false),
From(from),
IntrosetLocation(location),
RelayOrder(relayOrder),
TxID(txid)
{}
std::string PubIntroReceivedEvent::ToString() const
{
return "DhtPubIntroReceievedEvent on " + routerID.ShortString() + " from " + From.ToHex() + " location=" + IntrosetLocation.ToHex() + " order=" + std::to_string(RelayOrder) + " txid=" + std::to_string(TxID);
}
}

@ -0,0 +1,29 @@
#pragma once
#include "router_event.hpp"
#include "dht/key.hpp"
namespace tooling
{
struct FindIntroReceievedEvent : public RouterEvent
{
FindIntroReceievedEvent(const llarp::RouterID & ourRouter, const llarp::dht::Key_t & from, const llarp::dht::Key_t & location, uint64_t txid);
llarp::dht::Key_t From;
llarp::dht::Key_t IntrosetLocation;
uint64_t TxID;
std::string ToString() const override;
};
struct PubIntroReceivedEvent : public RouterEvent
{
PubIntroReceivedEvent(const llarp::RouterID & ourRouter, const llarp::dht::Key_t & from, const llarp::dht::Key_t & location, uint64_t txid, uint64_t relayOrder);
llarp::dht::Key_t From;
llarp::dht::Key_t IntrosetLocation;
uint64_t RelayOrder;
uint64_t TxID;
std::string ToString() const override;
};
}

@ -1,6 +1,7 @@
#include "common.hpp"
#include "tooling/router_event.hpp"
#include "tooling/dht_event.hpp"
#include <path/path.hpp>
@ -22,6 +23,11 @@ namespace tooling
.def_readonly("prevHop", &PathRequestReceivedEvent::prevHop)
.def_readonly("nextHop", &PathRequestReceivedEvent::nextHop)
.def_readonly("isEndpoint", &PathRequestReceivedEvent::isEndpoint);
py::class_<PubIntroReceivedEvent, RouterEvent>(mod, "DhtPubIntroReceievedEvent")
.def_readonly("from", &PubIntroReceivedEvent::From)
.def_readonly("location", &PubIntroReceivedEvent::IntrosetLocation)
.def_readonly("relayOrder", &PubIntroReceivedEvent::RelayOrder)
.def_readonly("txid", &PubIntroReceivedEvent::TxID);
}
} // namespace tooling

Loading…
Cancel
Save