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
: ClientDestination(keys, false, params), : ClientDestination(keys, false, params),
m_RemoteName(remoteName) {} m_RemoteName(remoteName) {}
void MatchedTunnelDestination::ResolveCurrentLeaseSet() void MatchedTunnelDestination::ResolveCurrentLeaseSet()
{ {
if(i2p::client::context.GetAddressBook().GetIdentHash(m_RemoteName, m_RemoteIdent)) if(i2p::client::context.GetAddressBook().GetIdentHash(m_RemoteName, m_RemoteIdent))
@ -35,7 +36,12 @@ namespace client
m_RemoteLeaseSet = ls; m_RemoteLeaseSet = ls;
} }
else 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
{ {
if(ClientDestination::Start()) if(ClientDestination::Start())
{ {
m_ResolveTimer = std::make_shared<boost::asio::deadline_timer>(GetService());
GetTunnelPool()->SetCustomPeerSelector(this); GetTunnelPool()->SetCustomPeerSelector(this);
ResolveCurrentLeaseSet(); ResolveCurrentLeaseSet();
return true; return true;
@ -55,7 +62,8 @@ namespace client
{ {
if(ClientDestination::Stop()) if(ClientDestination::Stop())
{ {
if(m_ResolveTimer)
m_ResolveTimer->cancel();
return true; return true;
} }
else else

1
MatchedDestination.h

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

Loading…
Cancel
Save