MCPcopy Create free account
hub / github.com/amule-project/amule / GetAvgFile

Method GetAvgFile

src/ServerList.cpp:956–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954
955
956uint32 CServerList::GetAvgFile() const
957{
958 //Since there is no real way to know how many files are in the kad network,
959 //I figure to try to use the ED2K network stats to find how many files the
960 //average user shares..
961 uint32 totaluser = 0;
962 uint32 totalfile = 0;
963 for (CInternalList::const_iterator it = m_servers.begin(); it != m_servers.end(); ++it){
964 const CServer* const curr = *it;
965 //If this server has reported Users/Files and doesn't limit it's files too much
966 //use this in the calculation..
967 if( curr->GetUsers() && curr->GetFiles() && curr->GetSoftFiles() > 1000 ) {
968 totaluser += curr->GetUsers();
969 totalfile += curr->GetFiles();
970 }
971 }
972 //If the user count is a little low, don't send back a average..
973 //I added 50 to the count as many servers do not allow a large amount of files to be shared..
974 //Therefore the estimate here will be lower then the actual.
975 //I would love to add a way for the client to send some statistics back so we could see the real
976 //values here..
977 if ( totaluser > 500000 ) {
978 return (totalfile/totaluser)+50;
979 } else {
980 return 0;
981 }
982}
983
984
985std::vector<const CServer*> CServerList::CopySnapshot() const

Callers 1

SetKademliaFilesMethod · 0.80

Calls 5

GetSoftFilesMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetUsersMethod · 0.45
GetFilesMethod · 0.45

Tested by

no test coverage detected