Skip to content

Commit 224fdb8

Browse files
committed
eth/protocols/snap: rename function
1 parent 916d2ef commit 224fdb8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

eth/protocols/snap/sync_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,9 +1321,8 @@ type kv struct {
13211321
k, v []byte
13221322
}
13231323

1324-
// Helper for sorting
1325-
func kvLessFunc(a, b *kv) bool {
1326-
return bytes.Compare(a.k, b.k) < 0
1324+
func (k *kv) less(other *kv) bool {
1325+
return bytes.Compare(k.k, other.k) < 0
13271326
}
13281327

13291328
func key32(i uint64) []byte {
@@ -1383,7 +1382,7 @@ func makeAccountTrieNoStorage(n int) (string, *trie.Trie, []*kv) {
13831382
accTrie.MustUpdate(elem.k, elem.v)
13841383
entries = append(entries, elem)
13851384
}
1386-
slices.SortFunc(entries, kvLessFunc)
1385+
slices.SortFunc(entries, (*kv).less)
13871386

13881387
// Commit the state changes into db and re-create the trie
13891388
// for accessing later.
@@ -1445,7 +1444,7 @@ func makeBoundaryAccountTrie(n int) (string, *trie.Trie, []*kv) {
14451444
accTrie.MustUpdate(elem.k, elem.v)
14461445
entries = append(entries, elem)
14471446
}
1448-
slices.SortFunc(entries, kvLessFunc)
1447+
slices.SortFunc(entries, (*kv).less)
14491448

14501449
// Commit the state changes into db and re-create the trie
14511450
// for accessing later.
@@ -1492,7 +1491,7 @@ func makeAccountTrieWithStorageWithUniqueStorage(accounts, slots int, code bool)
14921491
storageRoots[common.BytesToHash(key)] = stRoot
14931492
storageEntries[common.BytesToHash(key)] = stEntries
14941493
}
1495-
slices.SortFunc(entries, kvLessFunc)
1494+
slices.SortFunc(entries, (*kv).less)
14961495

14971496
// Commit account trie
14981497
root, set := accTrie.Commit(true)
@@ -1557,7 +1556,7 @@ func makeAccountTrieWithStorage(accounts, slots int, code, boundary bool) (strin
15571556
storageRoots[common.BytesToHash(key)] = stRoot
15581557
storageEntries[common.BytesToHash(key)] = stEntries
15591558
}
1560-
slices.SortFunc(entries, kvLessFunc)
1559+
slices.SortFunc(entries, (*kv).less)
15611560

15621561
// Commit account trie
15631562
root, set := accTrie.Commit(true)
@@ -1601,7 +1600,7 @@ func makeStorageTrieWithSeed(owner common.Hash, n, seed uint64, db *trie.Databas
16011600
trie.MustUpdate(elem.k, elem.v)
16021601
entries = append(entries, elem)
16031602
}
1604-
slices.SortFunc(entries, kvLessFunc)
1603+
slices.SortFunc(entries, (*kv).less)
16051604
root, nodes := trie.Commit(false)
16061605
return root, nodes, entries
16071606
}
@@ -1652,7 +1651,7 @@ func makeBoundaryStorageTrie(owner common.Hash, n int, db *trie.Database) (commo
16521651
trie.MustUpdate(elem.k, elem.v)
16531652
entries = append(entries, elem)
16541653
}
1655-
slices.SortFunc(entries, kvLessFunc)
1654+
slices.SortFunc(entries, (*kv).less)
16561655
root, nodes := trie.Commit(false)
16571656
return root, nodes, entries
16581657
}

0 commit comments

Comments
 (0)