mirror of https://github.com/oxen-io/lokinet
some refactoring of tooling code, added RCGossipReceivedEvent
parent
912e4267e4
commit
c8c66f0a5f
@ -0,0 +1,94 @@
|
||||
#include <tooling/path_event.hpp>
|
||||
|
||||
#include <path/path.hpp>
|
||||
#include <path/transit_hop.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
|
||||
PathAttemptEvent::PathAttemptEvent(const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::Path> path)
|
||||
: RouterEvent("PathAttemptEvent", routerID, false)
|
||||
, hops(path->hops)
|
||||
, pathid(path->hops[0].rxID)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
PathAttemptEvent::ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- [";
|
||||
|
||||
size_t i = 0;
|
||||
for (const auto& hop : hops)
|
||||
{
|
||||
i++;
|
||||
|
||||
result += llarp::RouterID(hop.rc.pubkey).ShortString();
|
||||
result += "]";
|
||||
|
||||
if (i != hops.size())
|
||||
{
|
||||
result += " -> [";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PathRequestReceivedEvent::PathRequestReceivedEvent(const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::TransitHop> hop)
|
||||
: RouterEvent("PathRequestReceivedEvent", routerID, true)
|
||||
, prevHop(hop->info.downstream)
|
||||
, nextHop(hop->info.upstream)
|
||||
, txid(hop->info.txID)
|
||||
, rxid(hop->info.rxID)
|
||||
{
|
||||
isEndpoint = false;
|
||||
if (routerID == nextHop)
|
||||
{
|
||||
isEndpoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
PathRequestReceivedEvent::ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- [";
|
||||
result += prevHop.ShortString();
|
||||
result += "] -> [*";
|
||||
result += routerID.ShortString();
|
||||
result += "] -> [";
|
||||
|
||||
if (isEndpoint)
|
||||
{
|
||||
result += "nowhere]";
|
||||
}
|
||||
else
|
||||
{
|
||||
result += nextHop.ShortString();
|
||||
result += "]";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PathStatusReceivedEvent::PathStatusReceivedEvent(const llarp::RouterID& routerID, const llarp::PathID_t rxid, uint64_t status)
|
||||
: RouterEvent("PathStatusReceivedEvent", routerID, true)
|
||||
, rxid(rxid)
|
||||
, status(status)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
PathStatusReceivedEvent::ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- path rxid: " + rxid.ShortHex();
|
||||
result += ", status: " + std::to_string(status);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace tooling
|
@ -0,0 +1,45 @@
|
||||
#include "router_event.hpp"
|
||||
|
||||
#include <path/path_types.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
|
||||
struct PathAttemptEvent : public RouterEvent
|
||||
{
|
||||
PathAttemptEvent(const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::Path> path);
|
||||
|
||||
std::string ToString() const override;
|
||||
|
||||
std::vector<llarp::path::PathHopConfig> hops;
|
||||
|
||||
llarp::PathID_t pathid;
|
||||
};
|
||||
|
||||
struct PathRequestReceivedEvent : public RouterEvent
|
||||
{
|
||||
PathRequestReceivedEvent(const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::TransitHop> hop);
|
||||
|
||||
std::string ToString() const override;
|
||||
|
||||
llarp::RouterID prevHop;
|
||||
llarp::RouterID nextHop;
|
||||
|
||||
llarp::PathID_t txid;
|
||||
llarp::PathID_t rxid;
|
||||
|
||||
bool isEndpoint = false;
|
||||
};
|
||||
|
||||
struct PathStatusReceivedEvent : public RouterEvent
|
||||
{
|
||||
PathStatusReceivedEvent(const llarp::RouterID& routerID, const llarp::PathID_t rxid, uint64_t status);
|
||||
|
||||
std::string ToString() const override;
|
||||
|
||||
llarp::PathID_t rxid;
|
||||
|
||||
uint64_t status;
|
||||
};
|
||||
|
||||
} // namespace tooling
|
@ -0,0 +1,24 @@
|
||||
#include <tooling/rc_event.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
RCGossipReceivedEvent::RCGossipReceivedEvent(const llarp::RouterID& routerID, const llarp::RouterContact& rc)
|
||||
: RouterEvent("RCGossipReceivedEvent", routerID, true)
|
||||
, rc(rc)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
RCGossipReceivedEvent::ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " ---- other RouterID: " + llarp::RouterID(rc.pubkey).ShortString();
|
||||
}
|
||||
|
||||
std::string
|
||||
RCGossipReceivedEvent::LongString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " ---- RC: " + rc.ToString();
|
||||
}
|
||||
|
||||
} // namespace tooling
|
||||
|
@ -0,0 +1,21 @@
|
||||
#include <tooling/router_event.hpp>
|
||||
|
||||
#include <router_contact.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
struct RCGossipReceivedEvent : public RouterEvent
|
||||
{
|
||||
RCGossipReceivedEvent(const llarp::RouterID& routerID, const llarp::RouterContact& rc);
|
||||
|
||||
std::string
|
||||
ToString() const override;
|
||||
|
||||
std::string
|
||||
LongString() const;
|
||||
|
||||
llarp::RouterContact rc;
|
||||
};
|
||||
|
||||
} // namespace tooling
|
||||
|
Loading…
Reference in New Issue