more dht fixing, only pick the most up to date entity for reply

pull/295/head
Jeff Becker 5 years ago
parent d7f715c632
commit e24b595191
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -32,7 +32,7 @@ namespace llarp
return; return;
} }
// pick newest if we have more than 1 result // pick newest if we have more than 1 result
if(valuesFound.size() > 1) if(valuesFound.size())
{ {
service::IntroSet found; service::IntroSet found;
for(const auto &introset : valuesFound) for(const auto &introset : valuesFound)

@ -40,6 +40,17 @@ namespace llarp
void void
RecursiveRouterLookup::SendReply() RecursiveRouterLookup::SendReply()
{ {
if(valuesFound.size())
{
RouterContact found;
for(const auto &rc : valuesFound)
{
if(found.OtherIsNewer(rc))
found = rc;
}
valuesFound.clear();
valuesFound.emplace_back(found);
}
if(resultHandler) if(resultHandler)
{ {
resultHandler(valuesFound); resultHandler(valuesFound);

@ -81,10 +81,10 @@ namespace llarp
handleResult(valuesFound); handleResult(valuesFound);
} }
// get newest introset // get newest introset
if(valuesFound.size() > 1) if(valuesFound.size())
{ {
llarp::service::IntroSet found; llarp::service::IntroSet found;
for(const auto & introset : valuesFound) for(const auto &introset : valuesFound)
if(found.OtherIsNewer(introset)) if(found.OtherIsNewer(introset))
found = introset; found = introset;
valuesFound.clear(); valuesFound.clear();

@ -96,7 +96,7 @@ namespace llarp
/// node nickname, yw kee /// node nickname, yw kee
llarp::AlignedBuffer< NICKLEN > nickname; llarp::AlignedBuffer< NICKLEN > nickname;
uint64_t last_updated; uint64_t last_updated = 0;
bool bool
BEncode(llarp_buffer_t *buf) const override; BEncode(llarp_buffer_t *buf) const override;

Loading…
Cancel
Save