Skip to content

Commit f027818

Browse files
cryylNashBC
authored andcommitted
fix to resolve comments
Signed-off-by: cryyl <[email protected]>
1 parent ae3bdea commit f027818

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core/blockchain.go

+9
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,15 @@ func (bc *BlockChain) cacheDiffLayer(diffLayer *types.DiffLayer, diffLayerCh cha
521521
sort.SliceStable(diffLayer.Storages, func(i, j int) bool {
522522
return diffLayer.Storages[i].Account.Hex() < diffLayer.Storages[j].Account.Hex()
523523
})
524+
for _, storage := range diffLayer.Storages {
525+
// Sort keys and vals by key.
526+
sort.SliceStable(storage.Keys, func(i, j int) bool {
527+
return storage.Keys[i] < storage.Keys[j]
528+
})
529+
sort.SliceStable(storage.Vals, func(i, j int) bool {
530+
return storage.Keys[i] < storage.Keys[j]
531+
})
532+
}
524533

525534
if bc.diffLayerCache.Len() >= diffLayerCacheLimit {
526535
bc.diffLayerCache.RemoveOldest()

core/state/statedb.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1603,12 +1603,8 @@ func (s *StateDB) SnapToDiffLayer() ([]common.Address, []types.DiffAccount, []ty
16031603
for accountHash, storage := range s.snapStorage {
16041604
keys := make([]string, 0, len(storage))
16051605
values := make([][]byte, 0, len(storage))
1606-
for k := range storage {
1606+
for k, v := range storage {
16071607
keys = append(keys, k)
1608-
}
1609-
sort.Strings(keys)
1610-
for _, k := range keys {
1611-
v := storage[k]
16121608
values = append(values, v)
16131609
}
16141610
storages = append(storages, types.DiffStorage{

0 commit comments

Comments
 (0)