fix(raft):fix raft peers unorder error in config

This commit is contained in:
jiangzhe 2020-09-21 19:53:47 +08:00
parent 2903a7ada2
commit 64a2b3fc46
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/binary"
"fmt"
"path/filepath"
"sort"
"sync"
"time"
@ -557,6 +558,9 @@ func GenerateRaftPeers(config *order.Config) ([]raft.Peer, error) {
for id, node := range nodes {
peers = append(peers, raft.Peer{ID: id, Context: node.Bytes()})
}
sort.Slice(peers, func(i, j int) bool {
return peers[i].ID < peers[j].ID
})
return peers, nil
}