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 811f97f938
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 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()))
}
}