shared_ptr for local destination in TunnelPool

This commit is contained in:
orignal 2015-12-16 14:52:48 -05:00
parent 8ad20c0db3
commit 4599f6919c
8 changed files with 30 additions and 18 deletions

View file

@ -21,11 +21,12 @@ namespace data
ReadFromBuffer ();
}
LeaseSet::LeaseSet (const i2p::tunnel::TunnelPool& pool):
LeaseSet::LeaseSet (std::shared_ptr<const i2p::tunnel::TunnelPool> pool):
m_IsValid (true)
{
if (!pool) return;
// header
const i2p::data::LocalDestination * localDestination = pool.GetLocalDestination ();
auto localDestination = pool->GetLocalDestination ();
if (!localDestination)
{
m_Buffer = nullptr;
@ -41,7 +42,7 @@ namespace data
auto signingKeyLen = localDestination->GetIdentity ()->GetSigningPublicKeyLen ();
memset (m_Buffer + m_BufferLen, 0, signingKeyLen);
m_BufferLen += signingKeyLen;
auto tunnels = pool.GetInboundTunnels (5); // 5 tunnels maximum
auto tunnels = pool->GetInboundTunnels (5); // 5 tunnels maximum
m_Buffer[m_BufferLen] = tunnels.size (); // num leases
m_BufferLen++;
// leases