version 0.1.10
[fms.git] / src / freenet / introductionpuzzlerequester.cpp
index 91c127e..830bdb3 100644 (file)
@@ -188,11 +188,21 @@ void IntroductionPuzzleRequester::PopulateIDList()
 {\r
        DateTime now;\r
        int id;\r
+       std::string limitnum="30";\r
+\r
+       // if we don't have an identity that we haven't seen yet, then set limit to 5\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey WHERE tblIdentity.IdentityID IS NULL;");\r
+       st.Step();\r
+       if(!st.RowReturned())\r
+       {\r
+               limitnum="5";\r
+       }\r
+       st.Finalize();\r
 \r
        now.SetToGMTime();\r
 \r
-       // select identities that aren't single use and have been seen today\r
-       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")+"';");\r
+       // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum )\r
+       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+";");\r
        st.Step();\r
 \r
        m_ids.clear();\r
@@ -233,7 +243,7 @@ void IntroductionPuzzleRequester::Process()
        // this will recheck for ids every minute\r
        DateTime now;\r
        now.SetToGMTime();\r
-       if(m_tempdate<(now-(1.0/1440.0)))\r
+       if(m_ids.size()==0 && m_tempdate<(now-(1.0/1440.0)))\r
        {\r
                PopulateIDList();\r
                m_tempdate=now;\r