From 0cedce4e19e8ea8f969090db7e670c631280e013 Mon Sep 17 00:00:00 2001 From: hongmengning Date: Thu, 14 Aug 2025 15:20:16 +0800 Subject: [PATCH] refactor: use slices.Sort where appropriate Signed-off-by: hongmengning --- db/trie/mptrie/sortedlist.go | 5 ++--- state/factory/workingset.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/db/trie/mptrie/sortedlist.go b/db/trie/mptrie/sortedlist.go index c857f1b18b..dd95eaade3 100644 --- a/db/trie/mptrie/sortedlist.go +++ b/db/trie/mptrie/sortedlist.go @@ -1,6 +1,7 @@ package mptrie import ( + "slices" "sort" ) @@ -31,9 +32,7 @@ func (sl *SortedList) sort() { if sl.sorted { return } - sort.Slice(sl.li, func(i, j int) bool { - return sl.li[i] < sl.li[j] - }) + slices.Sort(sl.li) sl.sorted = true } diff --git a/state/factory/workingset.go b/state/factory/workingset.go index 291a35d773..7a5bd8aedc 100644 --- a/state/factory/workingset.go +++ b/state/factory/workingset.go @@ -8,7 +8,7 @@ package factory import ( "context" "math/big" - "sort" + "slices" "time" erigonstate "github.com/erigontech/erigon/core/state" @@ -455,7 +455,7 @@ func (ws *workingSet) checkNonceContinuity(ctx context.Context, accountNonceMap if err != nil { return errors.Wrapf(err, "failed to get the confirmed nonce of address %s", srcAddr) } - sort.Slice(receivedNonces, func(i, j int) bool { return receivedNonces[i] < receivedNonces[j] }) + slices.Sort(receivedNonces) if useZeroNonce { pendingNonce = confirmedState.PendingNonceConsideringFreshAccount() } else {