From 46d2b3876020571e1608b120f886f9a3d46bb7ea Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 3 Jul 2014 14:47:12 -0400 Subject: [PATCH] keyspace rotation --- NetDb.cpp | 15 ++++++++++++++- NetDb.h | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index 64e1d250..542961b0 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -95,7 +95,7 @@ namespace data void NetDb::Run () { - uint32_t lastSave = 0, lastPublish = 0; + uint32_t lastSave = 0, lastPublish = 0, lastKeyspaceRotation = 0; m_IsRunning = true; while (m_IsRunning) { @@ -142,6 +142,11 @@ namespace data Publish (); lastPublish = ts; } + if (ts % 86400 < 60 && ts - lastKeyspaceRotation >= 60) // wihhin 1 minutes since midnight (86400 = 24*3600) + { + KeyspaceRotation (); + lastKeyspaceRotation = ts; + } } 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 (); + } } } diff --git a/NetDb.h b/NetDb.h index d9451f7c..5d369a99 100644 --- a/NetDb.h +++ b/NetDb.h @@ -95,12 +95,13 @@ namespace data void Publish (); void ValidateSubscriptions (); const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set& excluded) const; + void KeyspaceRotation (); RequestedDestination * CreateRequestedDestination (const IdentHash& dest, bool isLeaseSet, bool isExploratory = false); void DeleteRequestedDestination (const IdentHash& dest); void DeleteRequestedDestination (RequestedDestination * dest); - + private: std::map m_LeaseSets;