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

Method IsSourceRequestAllowed

src/DownloadClient.cpp:179–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179bool CUpDownClient::IsSourceRequestAllowed()
180{
181 //#warning REWRITE - Source swapping from eMule.
182 // 0.42e
183 uint64 dwTickCount = ::GetTickCount64() + CONNECTION_LATENCY;
184 uint64 nTimePassedClient = dwTickCount - GetLastSrcAnswerTime();
185 uint64 nTimePassedFile = dwTickCount - m_reqfile->GetLastAnsweredTime();
186 bool bNeverAskedBefore = (GetLastAskedForSources() == 0);
187
188 uint32 uSources = m_reqfile->GetSourceCount();
189 return (
190 // if client has the correct extended protocol
191 ExtProtocolAvailable() && (SupportsSourceExchange2() || GetSourceExchange1Version() > 1) &&
192 // AND if we need more sources
193 thePrefs::GetMaxSourcePerFileSoft() > uSources &&
194 // AND if...
195 (
196 //source is not complete and file is very rare
197 ( !m_bCompleteSource
198 && (bNeverAskedBefore || nTimePassedClient > SOURCECLIENTREASKS)
199 && (uSources <= RARE_FILE/5)
200 ) ||
201 //source is not complete and file is rare
202 ( !m_bCompleteSource
203 && (bNeverAskedBefore || nTimePassedClient > SOURCECLIENTREASKS)
204 && (uSources <= RARE_FILE || uSources - m_reqfile->GetValidSourcesCount() <= RARE_FILE / 2)
205 && (nTimePassedFile > SOURCECLIENTREASKF)
206 ) ||
207 // OR if file is not rare
208 ( (bNeverAskedBefore || nTimePassedClient > (unsigned)(SOURCECLIENTREASKS * MINCOMMONPENALTY))
209 && (nTimePassedFile > (unsigned)(SOURCECLIENTREASKF * MINCOMMONPENALTY))
210 )
211 )
212 );
213}
214
215
216void CUpDownClient::SendFileRequest()

Callers

nothing calls this directly

Calls 4

GetTickCount64Function · 0.85
GetLastAnsweredTimeMethod · 0.80
GetValidSourcesCountMethod · 0.80
GetSourceCountMethod · 0.45

Tested by

no test coverage detected