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

Method TransferredData

src/CorruptionBlackBox.cpp:78–112  ·  view source on GitHub ↗

Store a piece of received data (don't know if it's good or bad yet). Data is stored in a list for the chunk in belongs to.

Source from the content-addressed store, hash-verified

76// Store a piece of received data (don't know if it's good or bad yet).
77// Data is stored in a list for the chunk in belongs to.
78void CCorruptionBlackBox::TransferredData(uint64 nStartPos, uint64 nEndPos, uint32 senderIP)
79{
80 if (nStartPos > nEndPos) {
81 wxFAIL;
82 return;
83 }
84
85 // convert pos to relative block pos
86 uint16 nPart = (uint16)(nStartPos / PARTSIZE);
87 uint32 nRelStartPos = nStartPos - nPart*PARTSIZE;
88 uint32 nRelEndPos = nEndPos - nPart*PARTSIZE;
89 if (nRelEndPos >= PARTSIZE) {
90 // data crosses the partborder, split it
91 // (for the fun of it, this should never happen)
92 nRelEndPos = PARTSIZE-1;
93 TransferredData((nPart+1)*PARTSIZE, nEndPos, senderIP);
94 }
95 //
96 // Let's keep things simple.
97 // We don't request data we already have.
98 // We check if received data exceeds block boundaries.
99 // -> There should not be much overlap here.
100 // So just stuff everything received into the list and only join adjacent blocks.
101 //
102 CRecordList & list = m_Records[nPart]; // this creates the entry if it doesn't exist yet
103 bool merged = false;
104 for (CRecordList::iterator it = list.begin(); it != list.end() && !merged; ++it) {
105 merged = it->Merge(nRelStartPos, nRelEndPos, senderIP);
106 }
107 if (!merged) {
108 list.push_back(CCBBRecord(nRelStartPos, nRelEndPos, senderIP));
109 AddDebugLogLineN(logPartFile, CFormat("CorruptionBlackBox(%s): transferred: new record for part %d (%d - %d, %s)")
110 % m_partNumber % nPart % nRelStartPos % nRelEndPos % Uint32toStringIP(senderIP));
111 }
112}
113
114// Mark a piece of data as good or bad.
115// Piece is removed from the chunk list and added to the client's record.

Callers 1

WriteToBufferMethod · 0.80

Calls 7

CCBBRecordClass · 0.85
CFormatClass · 0.85
Uint32toStringIPFunction · 0.85
MergeMethod · 0.80
TransferredDataClass · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected