Browse Source

delay request

pull/843/head
Jeff Becker 8 years ago
parent
commit
89dfe2b763
  1. 12
      MatchedDestination.cpp
  2. 1
      MatchedDestination.h

12
MatchedDestination.cpp

@ -11,6 +11,7 @@ namespace client @@ -11,6 +11,7 @@ namespace client
: ClientDestination(keys, false, params),
m_RemoteName(remoteName) {}
void MatchedTunnelDestination::ResolveCurrentLeaseSet()
{
if(i2p::client::context.GetAddressBook().GetIdentHash(m_RemoteName, m_RemoteIdent))
@ -35,7 +36,12 @@ namespace client @@ -35,7 +36,12 @@ namespace client
m_RemoteLeaseSet = ls;
}
else
ResolveCurrentLeaseSet();
{
m_ResolveTimer->expires_from_now(boost::posix_time::seconds(1));
m_ResolveTimer->async_wait([&](const boost::system::error_code & ec) {
if(!ec) ResolveCurrentLeaseSet();
});
}
}
@ -43,6 +49,7 @@ namespace client @@ -43,6 +49,7 @@ namespace client
{
if(ClientDestination::Start())
{
m_ResolveTimer = std::make_shared<boost::asio::deadline_timer>(GetService());
GetTunnelPool()->SetCustomPeerSelector(this);
ResolveCurrentLeaseSet();
return true;
@ -55,7 +62,8 @@ namespace client @@ -55,7 +62,8 @@ namespace client
{
if(ClientDestination::Stop())
{
if(m_ResolveTimer)
m_ResolveTimer->cancel();
return true;
}
else

1
MatchedDestination.h

@ -28,6 +28,7 @@ namespace client @@ -28,6 +28,7 @@ namespace client
std::string m_RemoteName;
i2p::data::IdentHash m_RemoteIdent;
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
std::shared_ptr<boost::asio::deadline_timer> m_ResolveTimer;
};
}
}

Loading…
Cancel
Save