Skip to content

Commit

Permalink
Merge pull request #158 from Taraxa-project/fix_stats_migration
Browse files Browse the repository at this point in the history
chore: fix stats migration error when its running the second time
  • Loading branch information
kstdl authored Nov 13, 2023
2 parents e7cf574 + 8a434a4 commit 758f4e1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ func (m *AddValidatorRegistrationBlock) migrateStats(s *pebble.Storage) {
s.ForEachFromKey([]byte(pebble.GetPrefix(storage.AddressStats{})), last_key, func(key []byte, res []byte) bool {
err := rlp.DecodeBytes(res, &o)
if err != nil {
if err.Error() == "rlp: too few elements for migration.OldAddressStats" {
if err.Error() == "rlp: input list has too many elements for migration.OldStatsResponse, decoding into (migration.OldAddressStats).OldStatsResponse" {
// Check if it's really already migrated
var o storage.AddressStats
err := rlp.DecodeBytes(res, &o)
if err != nil {
log.WithFields(log.Fields{"migration": m.id, "error": err}).Fatal("Error decoding AddressStats")
}
return false
}
log.WithFields(log.Fields{"migration": m.id, "error": err}).Fatal("Error decoding OldAddressStats")
Expand Down

0 comments on commit 758f4e1

Please sign in to comment.