Skip to content

Commit 5499a2c

Browse files
committed
[lbry] claimtrie: more verbose error message in ResetHeight
1 parent fae4063 commit 5499a2c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

claimtrie/claimtrie.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,23 @@ func (ct *ClaimTrie) ResetHeight(height int32) error {
333333
if passedHashFork {
334334
names = nil // force them to reconsider all names
335335
}
336+
337+
var fullRebuildRequired bool
338+
336339
err = ct.merkleTrie.SetRoot(hash)
337340
if err == merkletrie.ErrFullRebuildRequired {
341+
fullRebuildRequired = true
342+
} else if err != nil {
343+
return errors.Wrapf(err, "setRoot")
344+
}
345+
346+
if fullRebuildRequired {
338347
ct.runFullTrieRebuild(names, nil)
339348
}
340349

341350
if !ct.MerkleHash().IsEqual(hash) {
342-
return errors.Errorf("unable to restore the hash at height %d", height)
351+
return errors.Errorf("unable to restore the hash at height %d"+
352+
" (fullTriedRebuilt: %t)", height, fullRebuildRequired)
343353
}
344354

345355
return errors.WithStack(ct.blockRepo.Delete(height+1, oldHeight))

0 commit comments

Comments
 (0)