X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ftrustlistinserter.cpp;h=5f2fbb8fb394d8f3deab05186d18844533b594cc;hb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;hp=bd8f87c9a89cd4c26cd2979fc06ec16a55d01e74;hpb=6b896a9e1dc143bba86795be1e9336549db9b85f;p=fms.git diff --git a/src/freenet/trustlistinserter.cpp b/src/freenet/trustlistinserter.cpp index bd8f87c..5f2fbb8 100644 --- a/src/freenet/trustlistinserter.cpp +++ b/src/freenet/trustlistinserter.cpp @@ -21,7 +21,13 @@ void TrustListInserter::CheckForNeededInsert() { DateTime date; date.SetToGMTime(); - date.Add(0,0,-1); + int currentday=date.GetDay(); + date.Add(0,0,-6); + // insert trust lists every 6 hours - if 6 hours ago was different day then set to midnight of current day to insert list today ASAP + if(currentday!=date.GetDay()) + { + date.Set(date.GetYear(),date.GetMonth(),currentday); + } SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID, PrivateKey FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND PublishTrustList='true' AND InsertingTrustList='false' AND (LastInsertedTrustList<='"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedTrustList IS NULL);"); if(rs.Empty()==false) @@ -93,7 +99,7 @@ const bool TrustListInserter::HandleMessage(FCPMessage &message) void TrustListInserter::Initialize() { - Option::instance()->Get("MessageBase",m_messagebase); + Option::Instance()->Get("MessageBase",m_messagebase); m_lastchecked.SetToGMTime(); } @@ -126,15 +132,18 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin std::string publickey; int messagetrust; int trustlisttrust; - DateTime now; + DateTime now,date; int index; std::string indexstr; std::string localidentityidstr; now.SetToGMTime(); - - // build the xml file - SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'';"); + date.SetToGMTime(); + + // build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities + date.Add(0,0,0,-20); // identities seen in last 20 days + SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;"); + st.Bind(0,date.Format("%Y-%m-%d")); st.Step(); while(st.RowReturned()) {