X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=03d4a419f3119ec3066192a70ff14f0e1c586ce0;hb=52c0819bfc1d083c6e0738f75f0d7eeba521295a;hp=c42e4cb44187bbaa424bdc09073629345aea7065;hpb=8adfd604a97d385869b0ce763b35d014d7aa2cca;p=fms.git diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index c42e4cb..03d4a41 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -64,6 +64,9 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) // parse file into xml and update the database if(xml.ParseXML(std::string(data.begin(),data.end()))==true) { + + // TODO - check if last part of UUID matches public key of identity who inserted it + st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);"); st.Bind(0,identityid); st.Bind(1,idparts[4]); @@ -169,7 +172,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 +183,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 +191,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 DESC LIMIT 0,"+limitnum+";"); st.Step(); m_ids.clear(); @@ -233,7 +246,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;