Skip to content

Commit 56e872d

Browse files
committed
Improve readability of code.
1 parent 0e5873c commit 56e872d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

service/service.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,15 @@ func (s *Service) HandleHello(ownAddress, remoteAddress string, req *HelloReques
905905
} else {
906906
// Need to check if this particular address does appear in
907907
// another peer, if so, we forbid to change the address:
908-
addrFound := false
909-
for j, pp := range s.myPeers.AllPeers {
910-
if j != i && pp.Address == slaveAddr {
911-
addrFound = true
908+
addrFoundInOtherPeer := false
909+
for _, pp := range s.myPeers.AllPeers {
910+
if pp.ID != req.SlaveID && pp.Address == slaveAddr {
911+
addrFoundInOtherPeer = true
912912
break
913913
}
914914
}
915915
// Slave address may not change in this case
916-
if addrFound && p.Address != slaveAddr {
916+
if addrFoundInOtherPeer && p.Address != slaveAddr {
917917
return ClusterConfig{}, maskAny(client.NewBadRequestError("Cannot change slave address while using an existing ID."))
918918
}
919919
// We accept the new address (it might be the old one):

0 commit comments

Comments
 (0)