refactor: remove peer_atom.shelfDate() (#3187)

This commit is contained in:
Charles Kerr 2022-06-03 10:09:16 -05:00 committed by GitHub
parent 79d90167fd
commit c5a73b0a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 48 deletions

View File

@ -116,7 +116,6 @@ struct peer_atom
, fromFirst{ from }
, fromBest{ from }
, flags{ flags_in }
, shelf_date_{ tr_time() + getDefaultShelfLife(from) + tr_rand_int_weak(60 * 10) }
{
}
@ -149,11 +148,6 @@ struct peer_atom
return value;
}
[[nodiscard]] constexpr auto shelfDate() const noexcept
{
return shelf_date_;
}
[[nodiscard]] int getReconnectIntervalSecs(time_t const now) const noexcept
{
auto sec = int{};
@ -240,43 +234,7 @@ struct peer_atom
bool is_connected = false;
private:
/* similar to a TTL field, but less rigid --
* if the swarm is small, the atom will be kept past this date. */
time_t const shelf_date_;
mutable std::optional<bool> blocklisted_;
static int getDefaultShelfLife(uint8_t from)
{
/* in general, peers obtained from firsthand contact
* are better than those from secondhand, etc etc */
switch (from)
{
case TR_PEER_FROM_INCOMING:
return 60 * 60 * 6;
case TR_PEER_FROM_LTEP:
return 60 * 60 * 6;
case TR_PEER_FROM_TRACKER:
return 60 * 60 * 3;
case TR_PEER_FROM_DHT:
return 60 * 60 * 3;
case TR_PEER_FROM_PEX:
return 60 * 60 * 2;
case TR_PEER_FROM_RESUME:
return 60 * 60;
case TR_PEER_FROM_LPD:
return 10 * 60;
default:
return 60 * 60;
}
}
};
// a container for keeping track of tr_handshakes
@ -2597,12 +2555,6 @@ struct CompareAtomsByActivity
return atime > btime ? -1 : 1;
}
// tertiary key: shelf date
if (a.shelfDate() != b.shelfDate())
{
return a.shelfDate() > b.shelfDate() ? -1 : 1;
}
return 0;
}