megaT, on 03 May 2023 - 07:06 PM, said:
Hi,
it's not a blackbox - you have to understand that the tree is growing from top-left to bottom-left.. so the left leaf's are favoured, the algorithm
tries to fulfill these parts of the tree at first.
Yes I know. Theres the flag that decides what goes to left or right. Beginning from top is left.
Quote
The 140K or 4.53 are both reminders of what's left in the level's.
Yes I know that 140k is a remainder of a whole part: 52*180k + 140k.
Quote
180K is no blackbox, this is the block size, 140K < 180K - so that's a reminder to what's left in that part of the tree.
With blackbox I mean how do I get 4.53/4.75 from a 9.28 node like in the example.
I never get this values, that was where the black box begun for me.
But in the meantime I found the error in my code…
Quote
if you want to know how the algorithm is working you need to read the source code - the diagram isn't sufficient.
There is the base size which is either the part or the block size if they file is too small.
Have you checked how the block count and the find function works?
Yes, I even implemented find more or less 1:1 and it works until I reach a 9.28 Node, from there I dont
get the 4.75,4.53 values.
The main part for building the tree is this code fragment. It appears in several places,
ASSERTs deleted here.
uint64 nBlocks = m_nDataSize / GetBaseSize() + static_cast<uint64>(m_nDataSize % GetBaseSize() != 0);
uint64 nLeft = (nBlocks + static_cast<unsigned>(m_bIsLeftBranch)) / 2 * GetBaseSize();
uint64 nRight = m_nDataSize - nLeft;
if (m_pLeftTree == NULL)
m_pLeftTree = new CAICHHashTree(nLeft, true, (nLeft <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE);
if (m_pRightTree == NULL)
m_pRightTree = new CAICHHashTree(nRight, false, (nRight <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE);
return m_pLeftTree->LoadLowestLevelHashes(fileInput) && m_pRightTree->LoadLowestLevelHashes(fileInput);
I rechecked my code and found out that my GetBaseSize was wrong. The emule code uses a flag to save space
saving the two values, I didnt do this but use the simple return from the original GetBaseSize that does
not do the check. The check is done in the original SetBaseSize. So my GetBaseSize always returns 9.28 - ARGH!
Thank you for your answers.