Skip to content

Commit

Permalink
fix to resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: cryyl <1226241521@qq.com>
  • Loading branch information
cryyl authored and NashBC committed May 5, 2022
1 parent ae3bdea commit f027818
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ func (bc *BlockChain) cacheDiffLayer(diffLayer *types.DiffLayer, diffLayerCh cha
sort.SliceStable(diffLayer.Storages, func(i, j int) bool {
return diffLayer.Storages[i].Account.Hex() < diffLayer.Storages[j].Account.Hex()
})
for _, storage := range diffLayer.Storages {
// Sort keys and vals by key.
sort.SliceStable(storage.Keys, func(i, j int) bool {
return storage.Keys[i] < storage.Keys[j]
})
sort.SliceStable(storage.Vals, func(i, j int) bool {
return storage.Keys[i] < storage.Keys[j]
})
}

if bc.diffLayerCache.Len() >= diffLayerCacheLimit {
bc.diffLayerCache.RemoveOldest()
Expand Down
6 changes: 1 addition & 5 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1603,12 +1603,8 @@ func (s *StateDB) SnapToDiffLayer() ([]common.Address, []types.DiffAccount, []ty
for accountHash, storage := range s.snapStorage {
keys := make([]string, 0, len(storage))
values := make([][]byte, 0, len(storage))
for k := range storage {
for k, v := range storage {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := storage[k]
values = append(values, v)
}
storages = append(storages, types.DiffStorage{
Expand Down

0 comments on commit f027818

Please sign in to comment.