mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
Add NetDb::VisitRandomRouterInfos
This commit is contained in:
parent
fa8548fe34
commit
970557660e
2 changed files with 49 additions and 13 deletions
8
NetDb.h
8
NetDb.h
|
@ -39,6 +39,9 @@ namespace data
|
|||
|
||||
/** function for visiting a router info we have locally */
|
||||
typedef std::function<void(const i2p::data::RouterInfo &)> RouterInfoVisitor;
|
||||
|
||||
/** function for visiting a router info and determining if we want to use it */
|
||||
typedef std::function<bool(const i2p::data::RouterInfo &)> RouterInfoFilter;
|
||||
|
||||
class NetDb
|
||||
{
|
||||
|
@ -49,8 +52,6 @@ namespace data
|
|||
|
||||
void Start ();
|
||||
void Stop ();
|
||||
/** block until netdb is ready, call only once*/
|
||||
void WaitForReady();
|
||||
|
||||
bool AddRouterInfo (const uint8_t * buf, int len);
|
||||
bool AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
|
||||
|
@ -96,6 +97,8 @@ namespace data
|
|||
void VisitStoredRouterInfos(RouterInfoVisitor v);
|
||||
/** visit all router infos we have loaded in memory, cheaper than VisitLocalRouterInfos but locks access while visiting */
|
||||
void VisitRouterInfos(RouterInfoVisitor v);
|
||||
/** visit N random router that match using filter, then visit them with a visitor, return number of RouterInfos that were visited */
|
||||
size_t VisitRandomRouterInfos(RouterInfoFilter f, RouterInfoVisitor v, size_t n);
|
||||
private:
|
||||
|
||||
void Load ();
|
||||
|
@ -112,7 +115,6 @@ namespace data
|
|||
std::shared_ptr<const RouterInfo> GetRandomRouter (Filter filter) const;
|
||||
|
||||
private:
|
||||
std::promise<void> m_Ready;
|
||||
|
||||
mutable std::mutex m_LeaseSetsMutex;
|
||||
std::map<IdentHash, std::shared_ptr<LeaseSet> > m_LeaseSets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue