@@ -30,7 +30,7 @@ import (
3030 "fmt"
3131 "math/big"
3232 "os"
33- "sort "
33+ "slices "
3434 "strconv"
3535
3636 "github.com/XinFinOrg/XDPoSChain/core"
@@ -39,23 +39,19 @@ import (
3939
4040type allocItem struct { Addr , Balance * big.Int }
4141
42- type allocList []allocItem
43-
44- func (a allocList ) Len () int { return len (a ) }
45- func (a allocList ) Less (i , j int ) bool { return a [i ].Addr .Cmp (a [j ].Addr ) < 0 }
46- func (a allocList ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
47-
48- func makelist (g * core.Genesis ) allocList {
49- a := make (allocList , 0 , len (g .Alloc ))
42+ func makelist (g * core.Genesis ) []allocItem {
43+ items := make ([]allocItem , 0 , len (g .Alloc ))
5044 for addr , account := range g .Alloc {
5145 if len (account .Storage ) > 0 || len (account .Code ) > 0 || account .Nonce != 0 {
5246 panic (fmt .Sprintf ("can't encode account %x" , addr ))
5347 }
5448 bigAddr := new (big.Int ).SetBytes (addr .Bytes ())
55- a = append (a , allocItem {bigAddr , account .Balance })
49+ items = append (items , allocItem {bigAddr , account .Balance })
5650 }
57- sort .Sort (a )
58- return a
51+ slices .SortFunc (items , func (a , b allocItem ) int {
52+ return a .Addr .Cmp (b .Addr )
53+ })
54+ return items
5955}
6056
6157func makealloc (g * core.Genesis ) string {
0 commit comments