recursive calculates missing hash from the existing ones overwrites existing hashs fails if no hash is found for any branch
| 155 | // overwrites existing hashs |
| 156 | // fails if no hash is found for any branch |
| 157 | bool 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 | |
| 184 | bool CAICHHashTree::VerifyHashTree(CAICHHashAlgo* hashalg, bool bDeleteBadTrees) |
| 185 | { |
no test coverage detected