[lbry] claimtrie: more verbose error message in ResetHeight

This commit is contained in:
Roy Lee 2022-07-17 11:06:34 -07:00
parent fae4063046
commit 5499a2c1b3

View file

@ -333,13 +333,23 @@ func (ct *ClaimTrie) ResetHeight(height int32) error {
if passedHashFork {
names = nil // force them to reconsider all names
}
var fullRebuildRequired bool
err = ct.merkleTrie.SetRoot(hash)
if err == merkletrie.ErrFullRebuildRequired {
fullRebuildRequired = true
} else if err != nil {
return errors.Wrapf(err, "setRoot")
}
if fullRebuildRequired {
ct.runFullTrieRebuild(names, nil)
}
if !ct.MerkleHash().IsEqual(hash) {
return errors.Errorf("unable to restore the hash at height %d", height)
return errors.Errorf("unable to restore the hash at height %d"+
" (fullTriedRebuilt: %t)", height, fullRebuildRequired)
}
return errors.WithStack(ct.blockRepo.Delete(height+1, oldHeight))