version 0.1.9
[fms.git] / src / freenet / trustlistrequester.cpp
index f14fc5b..3fd5d99 100644 (file)
@@ -205,7 +205,7 @@ const bool TrustListRequester::HandleMessage(FCPMessage &message)
 void TrustListRequester::Initialize()\r
 {\r
        std::string tempval="";\r
-       Option::instance()->Get("MaxIdentityRequests",tempval);\r
+       Option::Instance()->Get("MaxIdentityRequests",tempval);\r
        StringFunctions::Convert(tempval,m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
@@ -216,7 +216,7 @@ void TrustListRequester::Initialize()
        {\r
                m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxTrustListRequests is currently set at "+tempval+".  This value might be incorrectly configured.");\r
        }\r
-       Option::instance()->Get("MessageBase",m_messagebase);\r
+       Option::Instance()->Get("MessageBase",m_messagebase);\r
        m_tempdate.SetToGMTime();\r
 }\r
 \r
@@ -224,11 +224,16 @@ void TrustListRequester::PopulateIDList()
 {\r
        DateTime date;\r
        int id;\r
+       std::string sql;\r
 \r
        date.SetToGMTime();\r
 \r
        // select identities we want to query (we've seen them today and they are publishing trust list) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)\r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+       sql="SELECT IdentityID FROM tblIdentity ";\r
+       sql+="WHERE Name IS NOT NULL AND Name <> '' AND PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') )";\r
+       sql+="ORDER BY LocalTrustListTrust DESC, LastSeen;";\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare(sql);\r
        st.Step();\r
 \r
        m_ids.clear();\r
@@ -269,7 +274,7 @@ void TrustListRequester::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