Skip to content

Commit

Permalink
pass LocalDestination by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Apr 1, 2014
1 parent ee08d66 commit 81e0676
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ namespace stream
m_IdentHash = i2p::data::CalculateIdentHash (m_Keys.pub);
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
CryptoPP::Integer (m_Keys.signingPrivateKey, 20));
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this);
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
}

StreamingDestination::StreamingDestination (const std::string& fullPath): m_LeaseSet (nullptr)
Expand All @@ -357,7 +357,7 @@ namespace stream
s.read ((char *)&m_Keys, sizeof (m_Keys));
else
LogPrint ("Can't open file ", fullPath);
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this);
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
}

StreamingDestination::~StreamingDestination ()
Expand Down
2 changes: 1 addition & 1 deletion Tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace tunnel
return tunnel;
}

TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination * localDestination)
TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination& localDestination)
{
auto pool = new TunnelPool (localDestination);
m_Pools.push_back (pool);
Expand Down
2 changes: 1 addition & 1 deletion Tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace tunnel
void PostTunnelData (I2NPMessage * msg);
template<class TTunnel>
TTunnel * CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel = 0);
TunnelPool * CreateTunnelPool (i2p::data::LocalDestination * localDestination);
TunnelPool * CreateTunnelPool (i2p::data::LocalDestination& localDestination);
void DeleteTunnelPool (TunnelPool * pool);

private:
Expand Down
5 changes: 2 additions & 3 deletions TunnelPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace i2p
{
namespace tunnel
{
TunnelPool::TunnelPool (i2p::data::LocalDestination * localDestination, int numTunnels):
TunnelPool::TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels):
m_LocalDestination (localDestination), m_NumTunnels (numTunnels), m_LastOutboundTunnel (nullptr)
{
CryptoPP::AutoSeededRandomPool rnd;
Expand Down Expand Up @@ -40,8 +40,7 @@ namespace tunnel
expiredTunnel->SetTunnelPool (nullptr);
m_InboundTunnels.erase (expiredTunnel);
}
if (m_LocalDestination)
m_LocalDestination->UpdateLeaseSet ();
m_LocalDestination.UpdateLeaseSet ();
}

void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel)
Expand Down
4 changes: 2 additions & 2 deletions TunnelPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace tunnel
{
public:

TunnelPool (i2p::data::LocalDestination * localDestination, int numTunnels = 5);
TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels = 5);
~TunnelPool ();

const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
Expand All @@ -47,7 +47,7 @@ namespace tunnel
private:

uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256];
i2p::data::LocalDestination * m_LocalDestination;
i2p::data::LocalDestination& m_LocalDestination;
int m_NumTunnels;
std::set<InboundTunnel *, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first
std::set<OutboundTunnel *, TunnelCreationTimeCmp> m_OutboundTunnels;
Expand Down

0 comments on commit 81e0676

Please sign in to comment.