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

Method ReCalculateHash

src/SHAHashSet.cpp:157–182  ·  view source on GitHub ↗

recursive calculates missing hash from the existing ones overwrites existing hashs fails if no hash is found for any branch

Source from the content-addressed store, hash-verified

155// overwrites existing hashs
156// fails if no hash is found for any branch
157bool CAICHHashTree::ReCalculateHash(CAICHHashAlgo* hashalg, bool bDontReplace)
158{
159 if (m_pLeftTree && m_pRightTree) {
160 if ( !m_pLeftTree->ReCalculateHash(hashalg, bDontReplace) || !m_pRightTree->ReCalculateHash(hashalg, bDontReplace) ) {
161 return false;
162 }
163 if (bDontReplace && m_bHashValid) {
164 return true;
165 }
166 if (m_pRightTree->m_bHashValid && m_pLeftTree->m_bHashValid) {
167 hashalg->Reset();
168 hashalg->Add(m_pLeftTree->m_Hash.GetRawHash(), HASHSIZE);
169 hashalg->Add(m_pRightTree->m_Hash.GetRawHash(), HASHSIZE);
170 hashalg->Finish(m_Hash);
171 m_bHashValid = true;
172 return true;
173 } else {
174 return m_bHashValid;
175 }
176 } else if (m_pLeftTree == NULL && m_pRightTree == NULL) {
177 return true;
178 } else {
179 AddDebugLogLineN(logSHAHashSet, "ReCalculateHash failed - Hashtree incomplete");
180 return false;
181 }
182}
183
184bool CAICHHashTree::VerifyHashTree(CAICHHashAlgo* hashalg, bool bDeleteBadTrees)
185{

Callers 3

VerifyHashTreeMethod · 0.80
CreateHashFromInputMethod · 0.80
EntryMethod · 0.80

Calls 4

ResetMethod · 0.45
AddMethod · 0.45
GetRawHashMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected