void AddressBook::HandleSubscriptionsUpdateTimer (const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) { if (!m_SharedLocalDestination) return; // TODO: error handling if (m_IsLoaded && !m_IsDownloading && m_SharedLocalDestination->IsReady ()) { // pick random subscription CryptoPP::AutoSeededRandomPool rnd; auto ind = rnd.GenerateWord32 (0, m_Subscriptions.size() - 1); m_IsDownloading = true; m_Subscriptions[ind]->CheckSubscription (); } else { if (!m_IsLoaded) LoadHosts (); // try it again later m_SubscriptionsUpdateTimer->expires_from_now (boost::posix_time::minutes(INITIAL_SUBSCRIPTION_RETRY_TIMEOUT)); m_SubscriptionsUpdateTimer->async_wait (std::bind (&AddressBook::HandleSubscriptionsUpdateTimer, this, std::placeholders::_1)); } } }
const i2p::data::IdentHash * AddressBook::FindAddress (const std::string& address) { if (!m_IsLoaded) LoadHosts (); if (m_IsLoaded) { auto it = m_Addresses.find (address); if (it != m_Addresses.end ()) return &it->second; } return nullptr; }
bool LoadTranslator() { string Path; try { Path = GetIniFilePath() + "/translate.cfg"; } catch (...) { return false; }; vector<CHost> Hosts; LoadHosts(Path, Hosts); if (Hosts.size() != 1) { seman_daemon_log ( Format(" in %s should be only one host \n", Path.c_str() ) ); return false; }; assert (pGlobalSynHost == 0); pGlobalSynHost = new CTransHost(false, pdMediumDensity); pGlobalSynHost->CopyAddressParametersFrom(Hosts[0]); pGlobalSynHost->m_LogFunction = seman_daemon_log; GlobalErrorMessage = seman_daemon_log; //pGlobalSynHost->m_pdProtocolDensity = pdHeavyDensity; try { seman_daemon_log ( "Loading Translator\n"); translater = new RussianIntoEnglishTranslator; } catch (...) { seman_daemon_log ( " an exception occurred!\n"); return false; }; pGlobalSynHost->CreateListener(); return true; };