mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 01:46:36 +02:00
keyspace rotation
This commit is contained in:
parent
f2f4a0b04e
commit
46d2b38760
2 changed files with 16 additions and 2 deletions
15
NetDb.cpp
15
NetDb.cpp
|
@ -95,7 +95,7 @@ namespace data
|
||||||
|
|
||||||
void NetDb::Run ()
|
void NetDb::Run ()
|
||||||
{
|
{
|
||||||
uint32_t lastSave = 0, lastPublish = 0;
|
uint32_t lastSave = 0, lastPublish = 0, lastKeyspaceRotation = 0;
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
|
@ -142,6 +142,11 @@ namespace data
|
||||||
Publish ();
|
Publish ();
|
||||||
lastPublish = ts;
|
lastPublish = ts;
|
||||||
}
|
}
|
||||||
|
if (ts % 86400 < 60 && ts - lastKeyspaceRotation >= 60) // wihhin 1 minutes since midnight (86400 = 24*3600)
|
||||||
|
{
|
||||||
|
KeyspaceRotation ();
|
||||||
|
lastKeyspaceRotation = ts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
|
@ -724,5 +729,13 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetDb::KeyspaceRotation ()
|
||||||
|
{
|
||||||
|
for (auto it: m_RouterInfos)
|
||||||
|
it.second->UpdateRoutingKey ();
|
||||||
|
LogPrint ("Keyspace rotation complete");
|
||||||
|
Publish ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
NetDb.h
3
NetDb.h
|
@ -95,12 +95,13 @@ namespace data
|
||||||
void Publish ();
|
void Publish ();
|
||||||
void ValidateSubscriptions ();
|
void ValidateSubscriptions ();
|
||||||
const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||||
|
void KeyspaceRotation ();
|
||||||
|
|
||||||
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
||||||
bool isLeaseSet, bool isExploratory = false);
|
bool isLeaseSet, bool isExploratory = false);
|
||||||
void DeleteRequestedDestination (const IdentHash& dest);
|
void DeleteRequestedDestination (const IdentHash& dest);
|
||||||
void DeleteRequestedDestination (RequestedDestination * dest);
|
void DeleteRequestedDestination (RequestedDestination * dest);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
||||||
|
|
Loading…
Add table
Reference in a new issue