X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Funknownidentityrequester.cpp;fp=src%2Ffreenet%2Funknownidentityrequester.cpp;h=765eb3f0295429a11823e3753e2fb942c4ab2aae;hb=e662ea47fba8715474851ceebacba400984ee433;hp=0000000000000000000000000000000000000000;hpb=30c26abc85a6331fecdcb6b03813710bfbc63d3f;p=fms.git diff --git a/src/freenet/unknownidentityrequester.cpp b/src/freenet/unknownidentityrequester.cpp new file mode 100644 index 0000000..765eb3f --- /dev/null +++ b/src/freenet/unknownidentityrequester.cpp @@ -0,0 +1,53 @@ +#include "../../include/freenet/unknownidentityrequester.h" +#include "../../include/option.h" + +#ifdef XMEM + #include +#endif + +UnknownIdentityRequester::UnknownIdentityRequester() +{ + Initialize(); +} + +UnknownIdentityRequester::UnknownIdentityRequester(FCPv2 *fcp):IdentityRequester(fcp) +{ + Initialize(); +} + +void UnknownIdentityRequester::Initialize() +{ + m_fcpuniquename="UnknownIdentityRequester"; + Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests); + + // unknown identities get 1/5 of the max requests option - known identities get 4/5 + any remaining if not evenly divisible + m_maxrequests=(m_maxrequests/5); + + if(m_maxrequests<1) + { + m_maxrequests=1; + m_log->error("Option MaxIdentityRequests is currently set at less than 1. It must be 1 or greater."); + } + if(m_maxrequests>100) + { + m_log->warning("Option MaxIdentityRequests is currently set at more than 100. This value might be incorrectly configured."); + } +} + +void UnknownIdentityRequester::PopulateIDList() +{ + int id; + + // select identities we want to query (haven't seen at all) - sort by their trust level (descending) + SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen IS NULL ORDER BY LocalMessageTrust+LocalTrustListTrust DESC;"); + st.Step(); + + m_ids.clear(); + + while(st.RowReturned()) + { + st.ResultInt(0,id); + m_ids[id]=false; + st.Step(); + } +}