mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 09:50:45 +00:00
parent
525a84eae4
commit
31dcbc7645
2 changed files with 8 additions and 10 deletions
|
|
@ -251,6 +251,11 @@ func (a Address) IsZero() bool { return a == Address{} }
|
||||||
// Str gets the string representation of the underlying address
|
// Str gets the string representation of the underlying address
|
||||||
func (a Address) Str() string { return string(a[:]) }
|
func (a Address) Str() string { return string(a[:]) }
|
||||||
|
|
||||||
|
// Cmp compares two addresses.
|
||||||
|
func (a Address) Cmp(other Address) int {
|
||||||
|
return bytes.Compare(a[:], other[:])
|
||||||
|
}
|
||||||
|
|
||||||
// Bytes gets the string representation of the underlying address.
|
// Bytes gets the string representation of the underlying address.
|
||||||
func (a Address) Bytes() []byte { return a[:] }
|
func (a Address) Bytes() []byte { return a[:] }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
package tracers
|
package tracers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
@ -25,7 +24,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"slices"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -635,19 +634,13 @@ type Account struct {
|
||||||
addr common.Address
|
addr common.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
type Accounts []Account
|
func newAccounts(n int) (accounts []Account) {
|
||||||
|
|
||||||
func (a Accounts) Len() int { return len(a) }
|
|
||||||
func (a Accounts) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
||||||
func (a Accounts) Less(i, j int) bool { return bytes.Compare(a[i].addr.Bytes(), a[j].addr.Bytes()) < 0 }
|
|
||||||
|
|
||||||
func newAccounts(n int) (accounts Accounts) {
|
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
accounts = append(accounts, Account{key: key, addr: addr})
|
accounts = append(accounts, Account{key: key, addr: addr})
|
||||||
}
|
}
|
||||||
sort.Sort(accounts)
|
slices.SortFunc(accounts, func(a, b Account) int { return a.addr.Cmp(b.addr) })
|
||||||
return accounts
|
return accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue