mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
shared_ptr for Lease
This commit is contained in:
parent
16fe13bf4a
commit
7d927b0e28
6 changed files with 26 additions and 31 deletions
12
LeaseSet.cpp
12
LeaseSet.cpp
|
@ -128,7 +128,9 @@ namespace data
|
|||
m_ExpirationTime = lease.endDate;
|
||||
if (m_StoreLeases)
|
||||
{
|
||||
m_Leases.push_back (lease);
|
||||
auto l = std::make_shared<Lease>();
|
||||
*l = lease;
|
||||
m_Leases.push_back (l);
|
||||
// check if lease's gateway is in our netDb
|
||||
if (!netdb.FindRouter (lease.tunnelGateway))
|
||||
{
|
||||
|
@ -147,13 +149,13 @@ namespace data
|
|||
}
|
||||
}
|
||||
|
||||
const std::vector<Lease> LeaseSet::GetNonExpiredLeases (bool withThreshold) const
|
||||
const std::vector<std::shared_ptr<Lease> > LeaseSet::GetNonExpiredLeases (bool withThreshold) const
|
||||
{
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
std::vector<Lease> leases;
|
||||
std::vector<std::shared_ptr<Lease> > leases;
|
||||
for (auto& it: m_Leases)
|
||||
{
|
||||
auto endDate = it.endDate;
|
||||
auto endDate = it->endDate;
|
||||
if (!withThreshold)
|
||||
endDate -= i2p::tunnel::TUNNEL_EXPIRATION_THRESHOLD*1000;
|
||||
if (ts < endDate)
|
||||
|
@ -166,7 +168,7 @@ namespace data
|
|||
{
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
for (auto& it: m_Leases)
|
||||
if (ts >= it.endDate) return true;
|
||||
if (ts >= it->endDate) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue