Skip to content

Commit

Permalink
Omit re-create if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Feb 20, 2024
1 parent abfecd3 commit 13bc2e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion state/accountsDBApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,18 @@ func (accountsDB *accountsDBApi) RecreateTrieFromEpoch(options common.RootHashHo
accountsDB.mutRecreatedTrieBlockInfo.Lock()
defer accountsDB.mutRecreatedTrieBlockInfo.Unlock()

newBlockInfo := holders.NewBlockInfo([]byte{}, 0, options.GetRootHash())
if newBlockInfo.Equal(accountsDB.blockInfo) {
return nil
}

err := accountsDB.innerAccountsAdapter.RecreateTrieFromEpoch(options)
if err != nil {
accountsDB.blockInfo = nil
return err
}

accountsDB.blockInfo = holders.NewBlockInfo([]byte{}, 0, options.GetRootHash())
accountsDB.blockInfo = newBlockInfo

return nil
}
Expand Down

0 comments on commit 13bc2e4

Please sign in to comment.