From 5499a2c1b3999cfcf4ebdc108a9aeddeeed0b52c Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Sun, 17 Jul 2022 11:06:34 -0700 Subject: [PATCH] [lbry] claimtrie: more verbose error message in ResetHeight --- claimtrie/claimtrie.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/claimtrie/claimtrie.go b/claimtrie/claimtrie.go index 667916dd..2bc0cdbf 100644 --- a/claimtrie/claimtrie.go +++ b/claimtrie/claimtrie.go @@ -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))