From fdf5fce0536b8a28081d4dddc6948b4d84dc6fa5 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 27 Mar 2023 13:02:06 -0400 Subject: [PATCH] Update store.go --- store/store.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/store/store.go b/store/store.go index ccbe260e..ca365b4d 100644 --- a/store/store.go +++ b/store/store.go @@ -511,22 +511,20 @@ func (s *Store) IsLeader() bool { return s.raft.State() == raft.Leader } -// IsVoter returns true if the current node is a voter in the cluster. +// IsVoter returns true if the current node is a voter in the cluster. If there +// is no reference to the current node in the current cluster configuration then +// false will also be returned. func (s *Store) IsVoter() (bool, error) { cfg := s.raft.GetConfiguration() if err := cfg.Error(); err != nil { return false, err } - if len(cfg.Configuration().Servers) == 0 { - return false, nil - } - for _, srv := range cfg.Configuration().Servers { if srv.ID == raft.ServerID(s.raftID) { return srv.Suffrage == raft.Voter, nil } } - return false, fmt.Errorf("this node (id=%s) not found in configuration", s.raftID) + return false, nil } // State returns the current node's Raft state