#include "../../include/freenet/trustlistxml.h"\r
\r
#include <Poco/DateTimeFormatter.h>\r
+#include <Poco/Timespan.h>\r
\r
#ifdef XMEM\r
#include <xmem.h>\r
long index;\r
int insertcount=0;\r
int dayinsertcount=0;\r
+ int previnsertcount=0;\r
\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
StringFunctions::Convert(message["DataLength"],datalength);\r
\r
// get count of identities added in last 24 hours\r
st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity WHERE DateAdded>=?;");\r
+ now-=Poco::Timespan(1,0,0,0,0);\r
st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
if(st.RowReturned())\r
m_log->error("TrustListRequester::HandleAllData couldn't get count of identities added in last 24 hours");\r
}\r
\r
+ // get count of identities added more than 24 hours ago - if 0 then we will accept more than 100 identities now\r
+ st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity WHERE DateAdded<?;");\r
+ st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S"));\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ if(st.ResultNull(0)==false)\r
+ {\r
+ st.ResultInt(0,previnsertcount);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ m_log->error("TrustListRequester::HandleAllData couldn't get count of identities added more than 24 hours ago");\r
+ }\r
+\r
+ now=Poco::DateTime();\r
+\r
// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
st.Step();\r
if(st.RowReturned()==false)\r
{\r
- if(insertcount<50 && dayinsertcount<100)\r
+ if(insertcount<50 && (dayinsertcount<100 || previnsertcount==0))\r
{\r
idinsert.Bind(0,identity);\r
idinsert.Bind(1,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S"));\r
{\r
m_log->warning("TrustListRequester::HandleAllData TrustList contained more than 50 new identities : "+message["Identifier"]);\r
}\r
- if(dayinsertcount>=100)\r
+ if(dayinsertcount>=100 && previnsertcount>0)\r
{\r
m_log->warning("TrustListRequester::HandleAllData TrustList would have inserted more than 100 new identities in the last 24 hours : "+message["Identifier"]);\r
}\r
{\r
std::string tempval="";\r
m_fcpuniquename="TrustListRequester";\r
- Option::Instance()->Get("MaxIdentityRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r