X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=4f85e7a35f7f1c54267e1a50d77dd9d7713b9f70;hb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;hp=c42e4cb44187bbaa424bdc09073629345aea7065;hpb=8adfd604a97d385869b0ce763b35d014d7aa2cca;p=fms.git diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index c42e4cb..4f85e7a 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -169,7 +169,7 @@ const bool IntroductionPuzzleRequester::HandleMessage(FCPMessage &message) void IntroductionPuzzleRequester::Initialize() { std::string tempval=""; - Option::instance()->Get("MaxIntroductionPuzzleRequests",tempval); + Option::Instance()->Get("MaxIntroductionPuzzleRequests",tempval); StringFunctions::Convert(tempval,m_maxrequests); if(m_maxrequests<1) { @@ -180,7 +180,7 @@ void IntroductionPuzzleRequester::Initialize() { m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". This value might be incorrectly configured."); } - Option::instance()->Get("MessageBase",m_messagebase); + Option::Instance()->Get("MessageBase",m_messagebase); m_tempdate.SetToGMTime(); } @@ -188,11 +188,21 @@ void IntroductionPuzzleRequester::PopulateIDList() { DateTime now; int id; + std::string limitnum="30"; + + // if we don't have an identity that we haven't seen yet, then set limit to 5 + SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey WHERE tblIdentity.IdentityID IS NULL;"); + st.Step(); + if(!st.RowReturned()) + { + limitnum="5"; + } + st.Finalize(); now.SetToGMTime(); - // select identities that aren't single use and have been seen today - SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"';"); + // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum ) + st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust LIMIT 0,"+limitnum+";"); st.Step(); m_ids.clear(); @@ -233,7 +243,7 @@ void IntroductionPuzzleRequester::Process() // this will recheck for ids every minute DateTime now; now.SetToGMTime(); - if(m_tempdate<(now-(1.0/1440.0))) + if(m_ids.size()==0 && m_tempdate<(now-(1.0/1440.0))) { PopulateIDList(); m_tempdate=now;