breaking change: add timestamp to introset

i don't know why this wasn't here. i could've sworn it was.
pull/16/head
Jeff Becker 6 years ago
parent 468e879626
commit 6652cc4bde
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -190,7 +190,8 @@ service's signing key.
a: SI,
i: [ I, I, I, ... ],
k: "<1218 bytes sntrup4591761 public key block>",
n: "<16 bytes service topic (optional)>",
n: "<16 bytes service topic (optional)>",
t: timestamp_uint64_milliseconds_since_epoch_published_at,
v: 0,
w: optional proof of work,
z: "<64 bytes signature using service info signing key>"

@ -24,7 +24,8 @@ namespace llarp
std::vector< Introduction > I;
PQPubKey K;
Tag topic;
llarp::PoW* W = nullptr;
llarp_time_t T = 0;
llarp::PoW* W = nullptr;
llarp::Signature Z;
IntroSet() = default;
@ -34,6 +35,7 @@ namespace llarp
A = std::move(other.A);
I = std::move(other.I);
K = std::move(other.K);
T = std::move(other.T);
version = std::move(other.version);
topic = std::move(other.topic);
W = std::move(other.W);
@ -45,6 +47,7 @@ namespace llarp
A = other.A;
I = other.I;
K = other.K;
T = other.T;
version = other.version;
topic = other.topic;
if(other.W)
@ -60,6 +63,7 @@ namespace llarp
A = other.A;
I = other.I;
K = other.K;
T = other.T;
version = other.version;
topic = other.topic;
if(W)
@ -79,7 +83,7 @@ namespace llarp
bool
OtherIsNewer(const IntroSet& other) const
{
return GetNewestIntroExpiration() < other.GetNewestIntroExpiration();
return T < other.T;
}
friend std::ostream&
@ -88,7 +92,7 @@ namespace llarp
out << "A=[" << i.A << "] I=[";
for(const auto& intro : i.I)
{
out << intro << ",";
out << intro << ", ";
}
out << "]";
out << "K=" << i.K;
@ -101,6 +105,7 @@ namespace llarp
{
out << " topic=" << i.topic;
}
out << " T=" << i.T;
if(i.W)
{
out << " W=" << *i.W;

@ -35,6 +35,9 @@ namespace llarp
if(!BEncodeMaybeReadDictEntry("n", topic, read, key, buf))
return false;
if(!BEncodeMaybeReadDictInt("t", T, read, key, buf))
return false;
if(llarp_buffer_eq(key, "w"))
{
if(W)
@ -76,6 +79,10 @@ namespace llarp
if(!BEncodeWriteDictEntry("n", topic, buf))
return false;
}
// Timestamp published
if(!BEncodeWriteDictInt("t", T, buf))
return false;
// write version
if(!BEncodeWriteDictInt("v", version, buf))
return false;
@ -273,6 +280,9 @@ namespace llarp
{
if(i.I.size() == 0)
return false;
// set timestamp
// TODO: round to nearest 1000 ms
i.T = llarp_time_now_ms();
// set service info
i.A = pub;
// set public encryption key

Loading…
Cancel
Save