mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
publish
This commit is contained in:
parent
411ac5b898
commit
ce722e7a5e
24
NetDb.cpp
24
NetDb.cpp
@ -90,7 +90,7 @@ namespace data
|
|||||||
|
|
||||||
void NetDb::Run ()
|
void NetDb::Run ()
|
||||||
{
|
{
|
||||||
uint32_t lastTs = 0;
|
uint32_t lastSave = 0, lastPublish = 0;
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
@ -120,11 +120,16 @@ namespace data
|
|||||||
Explore ();
|
Explore ();
|
||||||
|
|
||||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
if (ts - lastTs >= 60) // save routers every minute
|
if (ts - lastSave >= 60) // save routers every minute
|
||||||
{
|
{
|
||||||
if (lastTs)
|
if (lastSave)
|
||||||
SaveUpdated (m_NetDbPath);
|
SaveUpdated (m_NetDbPath);
|
||||||
lastTs = ts;
|
lastSave = ts;
|
||||||
|
}
|
||||||
|
if (ts - lastPublish >= 600) // publish every 10 minutes
|
||||||
|
{
|
||||||
|
Publish ();
|
||||||
|
lastPublish = ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
@ -543,6 +548,17 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetDb::Publish ()
|
||||||
|
{
|
||||||
|
std::set<IdentHash> excluded; // TODO: fill up later
|
||||||
|
auto floodfill = GetClosestFloodfill (i2p::context.GetRouterInfo ().GetIdentHash (), excluded);
|
||||||
|
if (floodfill)
|
||||||
|
{
|
||||||
|
LogPrint ("Publishing our RouterInfo to ", floodfill->GetIdentHashAbbreviation ());
|
||||||
|
transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest,
|
||||||
bool isLeaseSet, bool isExploratory)
|
bool isLeaseSet, bool isExploratory)
|
||||||
{
|
{
|
||||||
|
1
NetDb.h
1
NetDb.h
@ -82,6 +82,7 @@ namespace data
|
|||||||
void SaveUpdated (const char * directory);
|
void SaveUpdated (const char * directory);
|
||||||
void Run (); // exploratory thread
|
void Run (); // exploratory thread
|
||||||
void Explore ();
|
void Explore ();
|
||||||
|
void Publish ();
|
||||||
const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||||
|
|
||||||
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user