|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
#include <util/time.hpp>
|
|
|
|
|
#include <util/status.hpp>
|
|
|
|
|
|
|
|
|
|
#include <absl/types/optional.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <iostream>
|
|
|
|
@ -31,75 +32,9 @@ namespace llarp
|
|
|
|
|
PQPubKey K;
|
|
|
|
|
Tag topic;
|
|
|
|
|
llarp_time_t T = 0;
|
|
|
|
|
std::unique_ptr< PoW > W;
|
|
|
|
|
absl::optional< PoW > W;
|
|
|
|
|
Signature Z;
|
|
|
|
|
|
|
|
|
|
IntroSet() = default;
|
|
|
|
|
|
|
|
|
|
IntroSet(IntroSet&& other) = default;
|
|
|
|
|
|
|
|
|
|
IntroSet(const IntroSet& other)
|
|
|
|
|
: IBEncodeMessage(other.version)
|
|
|
|
|
, A(other.A)
|
|
|
|
|
, I(other.I)
|
|
|
|
|
, K(other.K)
|
|
|
|
|
, topic(other.topic)
|
|
|
|
|
, T(other.T)
|
|
|
|
|
, W(std::make_unique< PoW >(*other.W))
|
|
|
|
|
, Z(other.Z)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntroSet&
|
|
|
|
|
operator=(const IntroSet& other)
|
|
|
|
|
{
|
|
|
|
|
I.clear();
|
|
|
|
|
A = other.A;
|
|
|
|
|
I = other.I;
|
|
|
|
|
K = other.K;
|
|
|
|
|
T = other.T;
|
|
|
|
|
version = other.version;
|
|
|
|
|
topic = other.topic;
|
|
|
|
|
W.reset();
|
|
|
|
|
if(other.W)
|
|
|
|
|
{
|
|
|
|
|
W = std::make_unique< PoW >(*other.W);
|
|
|
|
|
}
|
|
|
|
|
Z = other.Z;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
operator<(const IntroSet& other) const
|
|
|
|
|
{
|
|
|
|
|
return A < other.A;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
operator==(const IntroSet& other) const
|
|
|
|
|
{
|
|
|
|
|
if(std::tie(A, I, K, T, version, topic, Z)
|
|
|
|
|
!= std::tie(other.A, other.I, other.K, other.T, other.version,
|
|
|
|
|
other.topic, other.Z))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if(W && other.W) // both PoW have a valid ptr
|
|
|
|
|
{
|
|
|
|
|
return *W == *other.W;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return W == other.W; // if one is null, verify the other is null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
operator!=(const IntroSet& other) const
|
|
|
|
|
{
|
|
|
|
|
return !(*this == other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
OtherIsNewer(const IntroSet& other) const
|
|
|
|
|
{
|
|
|
|
@ -131,6 +66,27 @@ namespace llarp
|
|
|
|
|
ExtractStatus() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
|
operator<(const IntroSet& lhs, const IntroSet& rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.A < rhs.A;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
|
operator==(const IntroSet& lhs, const IntroSet& rhs)
|
|
|
|
|
{
|
|
|
|
|
return std::tie(lhs.A, lhs.I, lhs.K, lhs.T, lhs.version, lhs.topic, lhs.W,
|
|
|
|
|
lhs.Z)
|
|
|
|
|
== std::tie(rhs.A, rhs.I, rhs.K, rhs.T, rhs.version, rhs.topic, rhs.W,
|
|
|
|
|
rhs.Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
|
operator!=(const IntroSet& lhs, const IntroSet& rhs)
|
|
|
|
|
{
|
|
|
|
|
return !(lhs == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::ostream&
|
|
|
|
|
operator<<(std::ostream& out, const IntroSet& i)
|
|
|
|
|
{
|
|
|
|
|