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

Method SendHashsetPacket

src/UploadClient.cpp:528–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526
527
528void CUpDownClient::SendHashsetPacket(const CMD4Hash& forfileid)
529{
530 CKnownFile* file = theApp->sharedfiles->GetFileByID( forfileid );
531 bool from_dq = false;
532 if ( !file ) {
533 from_dq = true;
534 if ((file = theApp->downloadqueue->GetFileByID(forfileid)) == NULL) {
535 AddLogLineN(CFormat( _("Hashset requested for unknown file: %s") ) % forfileid.Encode() );
536
537 return;
538 }
539 }
540
541 if ( !file->GetHashCount() ) {
542 if (from_dq) {
543 AddDebugLogLineN(logRemoteClient, "Requested hashset could not be found");
544 return;
545 } else {
546 file = theApp->downloadqueue->GetFileByID(forfileid);
547 if (!(file && file->GetHashCount())) {
548 AddDebugLogLineN(logRemoteClient, "Requested hashset could not be found");
549 return;
550 }
551 }
552 }
553
554 CMemFile data(1024);
555 data.WriteHash(file->GetFileHash());
556 uint16 parts = file->GetHashCount();
557 data.WriteUInt16(parts);
558 for (int i = 0; i != parts; i++) {
559 data.WriteHash(file->GetPartHash(i));
560 }
561 CPacket* packet = new CPacket(data, OP_EDONKEYPROT, OP_HASHSETANSWER);
562 theStats::AddUpOverheadFileRequest(packet->GetPacketSize());
563 AddDebugLogLineN(logLocalClient, "Local Client: OP_HASHSETANSWER to " + GetFullIP());
564 SendPacket(packet,true,true);
565}
566
567
568void CUpDownClient::ClearUploadBlockRequests()

Callers 1

ProcessPacketMethod · 0.80

Calls 7

CFormatClass · 0.85
GetHashCountMethod · 0.80
WriteUInt16Method · 0.80
GetPacketSizeMethod · 0.80
GetFileByIDMethod · 0.45
EncodeMethod · 0.45
WriteHashMethod · 0.45

Tested by

no test coverage detected