Merge pull request #2047 from hashicorp/b-raft-peers

Remove unused peers variable from setupRaft().
This commit is contained in:
Sean Chittenden 2016-05-15 07:05:17 -07:00
commit cb144e34b3
1 changed files with 4 additions and 7 deletions

View File

@ -350,7 +350,6 @@ func (s *Server) setupRaft() error {
var log raft.LogStore var log raft.LogStore
var stable raft.StableStore var stable raft.StableStore
var snap raft.SnapshotStore var snap raft.SnapshotStore
var peers raft.PeerStore
if s.config.DevMode { if s.config.DevMode {
store := raft.NewInmemStore() store := raft.NewInmemStore()
@ -358,8 +357,7 @@ func (s *Server) setupRaft() error {
stable = store stable = store
log = store log = store
snap = raft.NewDiscardSnapshotStore() snap = raft.NewDiscardSnapshotStore()
peers = &raft.StaticPeers{} s.raftPeers = &raft.StaticPeers{}
s.raftPeers = peers
} else { } else {
// Create the base raft path // Create the base raft path
path := filepath.Join(s.config.DataDir, raftState) path := filepath.Join(s.config.DataDir, raftState)
@ -393,20 +391,19 @@ func (s *Server) setupRaft() error {
// Setup the peer store // Setup the peer store
s.raftPeers = raft.NewJSONPeers(path, trans) s.raftPeers = raft.NewJSONPeers(path, trans)
peers = s.raftPeers
} }
// Ensure local host is always included if we are in bootstrap mode // Ensure local host is always included if we are in bootstrap mode
if s.config.Bootstrap { if s.config.Bootstrap {
peers, err := s.raftPeers.Peers() peerAddrs, err := s.raftPeers.Peers()
if err != nil { if err != nil {
if s.raftStore != nil { if s.raftStore != nil {
s.raftStore.Close() s.raftStore.Close()
} }
return err return err
} }
if !raft.PeerContained(peers, trans.LocalAddr()) { if !raft.PeerContained(peerAddrs, trans.LocalAddr()) {
s.raftPeers.SetPeers(raft.AddUniquePeer(peers, trans.LocalAddr())) s.raftPeers.SetPeers(raft.AddUniquePeer(peerAddrs, trans.LocalAddr()))
} }
} }