X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzlerequester.cpp;h=4f85e7a35f7f1c54267e1a50d77dd9d7713b9f70;hb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;hp=70a2e8ecb37b166f7d3feb4574a1de9ebc127514;hpb=d8f51eac91f86a1e00a05a5058a8fa9eb8732464;p=fms.git diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index 70a2e8e..4f85e7a 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -76,7 +76,7 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed IntroductionPuzzle XML file : "+message["Identifier"]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IntroductionPuzzleRequester::HandleAllData parsed IntroductionPuzzle XML file : "+message["Identifier"]); } else { @@ -88,7 +88,7 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" error parsing IntroductionPuzzle XML file : "+message["Identifier"]); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData error parsing IntroductionPuzzle XML file : "+message["Identifier"]); } // remove this identityid from request list @@ -121,7 +121,7 @@ const bool IntroductionPuzzleRequester::HandleGetFailed(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" fatal error requesting "+message["Identifier"]); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleGetFailed fatal error requesting "+message["Identifier"]); } // remove this identityid from request list @@ -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;