X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=4f85e7a35f7f1c54267e1a50d77dd9d7713b9f70;hp=44c165a9a5256554460e272973b3b9fc09d5961f;hb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;hpb=37a8d59548287dcad78ef00e7b18058721eb9935 diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index 44c165a..4f85e7a 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -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();