Skip to content

Commit

Permalink
eth/protocols/snap: rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Jun 19, 2023
1 parent 916d2ef commit 224fdb8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions eth/protocols/snap/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,9 +1321,8 @@ type kv struct {
k, v []byte
}

// Helper for sorting
func kvLessFunc(a, b *kv) bool {
return bytes.Compare(a.k, b.k) < 0
func (k *kv) less(other *kv) bool {
return bytes.Compare(k.k, other.k) < 0
}

func key32(i uint64) []byte {
Expand Down Expand Up @@ -1383,7 +1382,7 @@ func makeAccountTrieNoStorage(n int) (string, *trie.Trie, []*kv) {
accTrie.MustUpdate(elem.k, elem.v)
entries = append(entries, elem)
}
slices.SortFunc(entries, kvLessFunc)
slices.SortFunc(entries, (*kv).less)

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

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

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

// Commit account trie
root, set := accTrie.Commit(true)
Expand Down Expand Up @@ -1601,7 +1600,7 @@ func makeStorageTrieWithSeed(owner common.Hash, n, seed uint64, db *trie.Databas
trie.MustUpdate(elem.k, elem.v)
entries = append(entries, elem)
}
slices.SortFunc(entries, kvLessFunc)
slices.SortFunc(entries, (*kv).less)
root, nodes := trie.Commit(false)
return root, nodes, entries
}
Expand Down Expand Up @@ -1652,7 +1651,7 @@ func makeBoundaryStorageTrie(owner common.Hash, n int, db *trie.Database) (commo
trie.MustUpdate(elem.k, elem.v)
entries = append(entries, elem)
}
slices.SortFunc(entries, kvLessFunc)
slices.SortFunc(entries, (*kv).less)
root, nodes := trie.Commit(false)
return root, nodes, entries
}
Expand Down

0 comments on commit 224fdb8

Please sign in to comment.