mirror of https://github.com/status-im/consul.git
Merge pull request #2047 from hashicorp/b-raft-peers
Remove unused peers variable from setupRaft().
This commit is contained in:
commit
cb144e34b3
|
@ -350,7 +350,6 @@ func (s *Server) setupRaft() error {
|
|||
var log raft.LogStore
|
||||
var stable raft.StableStore
|
||||
var snap raft.SnapshotStore
|
||||
var peers raft.PeerStore
|
||||
|
||||
if s.config.DevMode {
|
||||
store := raft.NewInmemStore()
|
||||
|
@ -358,8 +357,7 @@ func (s *Server) setupRaft() error {
|
|||
stable = store
|
||||
log = store
|
||||
snap = raft.NewDiscardSnapshotStore()
|
||||
peers = &raft.StaticPeers{}
|
||||
s.raftPeers = peers
|
||||
s.raftPeers = &raft.StaticPeers{}
|
||||
} else {
|
||||
// Create the base raft path
|
||||
path := filepath.Join(s.config.DataDir, raftState)
|
||||
|
@ -393,20 +391,19 @@ func (s *Server) setupRaft() error {
|
|||
|
||||
// Setup the peer store
|
||||
s.raftPeers = raft.NewJSONPeers(path, trans)
|
||||
peers = s.raftPeers
|
||||
}
|
||||
|
||||
// Ensure local host is always included if we are in bootstrap mode
|
||||
if s.config.Bootstrap {
|
||||
peers, err := s.raftPeers.Peers()
|
||||
peerAddrs, err := s.raftPeers.Peers()
|
||||
if err != nil {
|
||||
if s.raftStore != nil {
|
||||
s.raftStore.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
if !raft.PeerContained(peers, trans.LocalAddr()) {
|
||||
s.raftPeers.SetPeers(raft.AddUniquePeer(peers, trans.LocalAddr()))
|
||||
if !raft.PeerContained(peerAddrs, trans.LocalAddr()) {
|
||||
s.raftPeers.SetPeers(raft.AddUniquePeer(peerAddrs, trans.LocalAddr()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue