mirror of https://github.com/oxen-io/lokinet
Remove some .cpp files related to RouterEvents
The motivation is to reduce the raw amount of code required to create and maintain events.pull/1167/head
parent
4c6be3c8d1
commit
8a12da8bd5
@ -1,62 +0,0 @@
|
||||
#include "dht_event.hpp"
|
||||
#include "service/intro_set.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("DHT: PubIntroReceivedEvent", ourRouter, true)
|
||||
, From(from)
|
||||
, IntrosetLocation(location)
|
||||
, RelayOrder(relayOrder)
|
||||
, TxID(txid)
|
||||
{
|
||||
}
|
||||
|
||||
PubIntroSentEvent::PubIntroSentEvent(const llarp::RouterID& ourRouter,
|
||||
const llarp::dht::Key_t& introsetPubkey,
|
||||
const llarp::RouterID& relay,
|
||||
uint64_t relayIndex)
|
||||
: RouterEvent("DHT: PubIntroSentEvent", ourRouter, false)
|
||||
, introsetPubkey(introsetPubkey)
|
||||
, relay(relay)
|
||||
, relayIndex(relayIndex)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
PubIntroSentEvent::ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " ---- introset pubkey: "
|
||||
+ introsetPubkey.ShortHex() + ", relay: " + relay.ShortString()
|
||||
+ ", relayIndex: " + std::to_string(relayIndex);
|
||||
}
|
||||
|
||||
std::string
|
||||
PubIntroReceivedEvent::ToString() const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace tooling
|
@ -1,118 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
PathBuildRejectedEvent::PathBuildRejectedEvent(
|
||||
const llarp::RouterID& routerID,
|
||||
const llarp::PathID_t rxid_,
|
||||
const llarp::RouterID& rejectedBy_)
|
||||
: RouterEvent("PathBuildRejectedEvent", routerID, false)
|
||||
, rxid(rxid_)
|
||||
, rejectedBy(rejectedBy_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
PathBuildRejectedEvent::ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- path rxid: " + rxid.ShortHex();
|
||||
result += ", rejectedBy: " + rejectedBy.ShortString();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace tooling
|
@ -1,65 +1,147 @@
|
||||
#include "router_event.hpp"
|
||||
|
||||
#include <path/path_types.hpp>
|
||||
#include <path/path.hpp>
|
||||
#include <path/transit_hop.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
struct PathAttemptEvent : public RouterEvent
|
||||
{
|
||||
PathAttemptEvent(const llarp::RouterID& routerID,
|
||||
std::shared_ptr< const llarp::path::Path > path);
|
||||
std::vector< llarp::path::PathHopConfig > hops;
|
||||
llarp::PathID_t pathid;
|
||||
|
||||
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
|
||||
ToString() const override;
|
||||
ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- [";
|
||||
|
||||
std::vector< llarp::path::PathHopConfig > hops;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
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(routerID == nextHop ? true : false)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const override;
|
||||
|
||||
llarp::PathID_t rxid;
|
||||
std::string
|
||||
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;
|
||||
}
|
||||
|
||||
uint64_t status;
|
||||
};
|
||||
|
||||
struct PathBuildRejectedEvent : public RouterEvent
|
||||
struct PathStatusReceivedEvent : public RouterEvent
|
||||
{
|
||||
PathBuildRejectedEvent(const llarp::RouterID& routerID,
|
||||
const llarp::PathID_t rxid,
|
||||
const llarp::RouterID& rejectedBy);
|
||||
llarp::PathID_t rxid;
|
||||
uint64_t status;
|
||||
|
||||
PathStatusReceivedEvent(
|
||||
const llarp::RouterID& routerID,
|
||||
const llarp::PathID_t rxid_,
|
||||
uint64_t status_)
|
||||
: RouterEvent("PathStatusReceivedEvent", routerID, true)
|
||||
, rxid(rxid_)
|
||||
, status(status_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const override;
|
||||
ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- path rxid: " + rxid.ShortHex();
|
||||
result += ", status: " + std::to_string(status);
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct PathBuildRejectedEvent : public RouterEvent
|
||||
{
|
||||
llarp::PathID_t rxid;
|
||||
llarp::RouterID rejectedBy;
|
||||
|
||||
PathBuildRejectedEvent(
|
||||
const llarp::RouterID& routerID,
|
||||
const llarp::PathID_t rxid_,
|
||||
const llarp::RouterID& rejectedBy_)
|
||||
: RouterEvent("PathBuildRejectedEvent", routerID, false)
|
||||
, rxid(rxid_)
|
||||
, rejectedBy(rejectedBy_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const
|
||||
{
|
||||
std::string result = RouterEvent::ToString();
|
||||
result += "---- path rxid: " + rxid.ShortHex();
|
||||
result += ", rejectedBy: " + rejectedBy.ShortString();
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tooling
|
||||
|
@ -1,43 +0,0 @@
|
||||
#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();
|
||||
}
|
||||
|
||||
RCGossipSentEvent::RCGossipSentEvent(const llarp::RouterID& routerID,
|
||||
const llarp::RouterContact& rc)
|
||||
: RouterEvent("RCGossipSentEvent", routerID, true), rc(rc)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
RCGossipSentEvent::ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " ---- sending RC for RouterID: "
|
||||
+ llarp::RouterID(rc.pubkey).ShortString();
|
||||
}
|
||||
|
||||
std::string
|
||||
RCGossipSentEvent::LongString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " ---- RC: " + rc.ToString();
|
||||
}
|
||||
|
||||
} // namespace tooling
|
@ -1,22 +0,0 @@
|
||||
#include <tooling/router_event.hpp>
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
RouterEvent::RouterEvent(std::string eventType, llarp::RouterID routerID,
|
||||
bool triggered)
|
||||
: eventType(eventType), routerID(routerID), triggered(triggered)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
RouterEvent::ToString() const
|
||||
{
|
||||
std::string result;
|
||||
result += eventType;
|
||||
result += " [";
|
||||
result += routerID.ShortString();
|
||||
result += "] -- ";
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace tooling
|
Loading…
Reference in New Issue