From 13bc2e4865fcded4d24cfbb6edd0580767c43583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Tue, 20 Feb 2024 13:09:41 +0200 Subject: [PATCH] Omit re-create if possible. --- state/accountsDBApi.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/state/accountsDBApi.go b/state/accountsDBApi.go index d9bd467d7d2..ae3ca439984 100644 --- a/state/accountsDBApi.go +++ b/state/accountsDBApi.go @@ -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 }