mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Add GotIntro event to RouterHive
This commit is contained in:
parent
68c1ae52b3
commit
4741d81051
|
@ -1,10 +1,12 @@
|
|||
#include <dht/messages/gotintro.hpp>
|
||||
|
||||
#include <service/intro.hpp>
|
||||
#include <dht/context.hpp>
|
||||
#include <memory>
|
||||
#include <path/path_context.hpp>
|
||||
#include <router/abstractrouter.hpp>
|
||||
#include <routing/dht_message.hpp>
|
||||
#include <tooling/dht_event.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace llarp
|
||||
|
@ -23,6 +25,14 @@ namespace llarp
|
|||
std::vector< std::unique_ptr< IMessage > > & /*replies*/) const
|
||||
{
|
||||
auto &dht = *ctx->impl;
|
||||
auto *router = dht.GetRouter();
|
||||
|
||||
auto ev = std::make_unique<tooling::GotIntroReceivedEvent>(
|
||||
router->pubkey(),
|
||||
Key_t(From.data()),
|
||||
(found.size() > 0 ? found[0] : llarp::service::EncryptedIntroSet{}),
|
||||
txid);
|
||||
router->NotifyRouterEvent(std::move(ev));
|
||||
|
||||
for(const auto &introset : found)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "dht_event.hpp"
|
||||
#include "service/intro_set.hpp"
|
||||
|
||||
|
||||
namespace tooling
|
||||
|
@ -16,4 +17,21 @@ namespace tooling
|
|||
return RouterEvent::ToString() + "from " + From.ShortHex() + " location=" + IntrosetLocation.ShortHex() + " order=" + std::to_string(RelayOrder) + " txid=" + std::to_string(TxID);
|
||||
}
|
||||
|
||||
GotIntroReceivedEvent::GotIntroReceivedEvent(
|
||||
const llarp::RouterID& ourRouter_,
|
||||
const llarp::dht::Key_t& from_,
|
||||
const llarp::service::EncryptedIntroSet & introset_,
|
||||
uint64_t txid_)
|
||||
: RouterEvent("DHT:: GotIntroReceivedEvent", ourRouter_, true)
|
||||
, From(from_)
|
||||
, Introset(introset_)
|
||||
, TxID(txid_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string GotIntroReceivedEvent::ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + "from " + From.ShortHex() + " location=" + Introset.derivedSigningKey.ShortHex() + " order=" + std::to_string(RelayOrder) + " txid=" + std::to_string(TxID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "router_event.hpp"
|
||||
#include "dht/key.hpp"
|
||||
#include "service/intro_set.hpp"
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
|
@ -26,4 +27,21 @@ namespace tooling
|
|||
uint64_t TxID;
|
||||
std::string ToString() const override;
|
||||
};
|
||||
|
||||
struct GotIntroReceivedEvent : public RouterEvent
|
||||
{
|
||||
// TODO: thought: why not just use the original message object here?
|
||||
// TODO: question: what ties this to the actual logic that knows an event occurred?
|
||||
GotIntroReceivedEvent(
|
||||
const llarp::RouterID & ourRouter,
|
||||
const llarp::dht::Key_t & from,
|
||||
const llarp::service::EncryptedIntroSet & introset,
|
||||
uint64_t txid);
|
||||
|
||||
llarp::dht::Key_t From;
|
||||
llarp::service::EncryptedIntroSet Introset;
|
||||
uint64_t RelayOrder;
|
||||
uint64_t TxID;
|
||||
std::string ToString() const override;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace tooling
|
|||
.def_readonly("location", &PubIntroReceivedEvent::IntrosetLocation)
|
||||
.def_readonly("relayOrder", &PubIntroReceivedEvent::RelayOrder)
|
||||
.def_readonly("txid", &PubIntroReceivedEvent::TxID);
|
||||
py::class_<GotIntroReceivedEvent, RouterEvent>(mod, "DhtGotIntroReceievedEvent")
|
||||
.def_readonly("from", &GotIntroReceivedEvent::From)
|
||||
.def_readonly("location", &GotIntroReceivedEvent::Introset)
|
||||
.def_readonly("relayOrder", &GotIntroReceivedEvent::RelayOrder)
|
||||
.def_readonly("txid", &GotIntroReceivedEvent::TxID);
|
||||
}
|
||||
|
||||
} // namespace tooling
|
||||
|
|
Loading…
Reference in a new issue