From 185d924e99c67b819ec01d2c5b07b59de0fb7a21 Mon Sep 17 00:00:00 2001 From: dean65 Date: Fri, 6 May 2022 01:26:13 +0800 Subject: [PATCH] fix sorting storage does not change original difflayer --- core/blockchain.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index a6f20cf6b7..4fe1bdae38 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -521,13 +521,13 @@ 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 { + for index := 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(diffLayer.Storages[index].Keys, func(i, j int) bool { + return diffLayer.Storages[index].Keys[i] < diffLayer.Storages[index].Keys[j] }) - sort.SliceStable(storage.Vals, func(i, j int) bool { - return storage.Keys[i] < storage.Keys[j] + sort.SliceStable(diffLayer.Storages[index].Vals, func(i, j int) bool { + return diffLayer.Storages[index].Keys[i] < diffLayer.Storages[index].Keys[j] }) }