Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort storage_flush_cache #2693

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions arbos/util/storage_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package util

import (
"github.com/ethereum/go-ethereum/common"
"slices"
)

type storageCacheEntry struct {
Expand Down Expand Up @@ -67,6 +68,10 @@ func (s *storageCache) Flush() []storageCacheStores {
})
}
}
sortFunc := func(a, b storageCacheStores) int {
return a.Key.Cmp(b.Key)
}
slices.SortFunc(stores, sortFunc)
return stores
}

Expand Down
3 changes: 1 addition & 2 deletions arbos/util/storage_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package util

import (
"bytes"
"slices"
"testing"

Expand Down Expand Up @@ -76,7 +75,7 @@ func TestStorageCache(t *testing.T) {
{Key: keys[2], Value: values[2]},
}
sortFunc := func(a, b storageCacheStores) int {
return bytes.Compare(a.Key.Bytes(), b.Key.Bytes())
return a.Key.Cmp(b.Key)
}
slices.SortFunc(stores, sortFunc)
slices.SortFunc(expected, sortFunc)
Expand Down
Loading