use quorum instead of all
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m57s

This commit is contained in:
matst80
2024-11-11 18:36:54 +01:00
parent 5ef0afcbf6
commit 7cdd38b389

View File

@@ -302,14 +302,23 @@ func (r *RemoteHost) ConfirmChange(id CartId, host string) error {
} }
func (p *SyncedPool) RequestOwnership(id CartId) error { func (p *SyncedPool) RequestOwnership(id CartId) error {
ok := 0
all := 0
for _, r := range p.remotes { for _, r := range p.remotes {
log.Printf("Confirming change of %s to %s (me) with %s\n", id, p.Hostname, r.Host) // log.Printf("Confirming change of %s to %s (me) with %s\n", id, p.Hostname, r.Host)
err := r.ConfirmChange(id, p.Hostname) err := r.ConfirmChange(id, p.Hostname)
all++
if err != nil { if err != nil {
log.Printf("Error confirming change: %v from %s\n", err, p.Hostname) log.Printf("Error confirming change: %v from %s\n", err, p.Hostname)
return err continue
} }
ok++
}
if ok == 0 && all > 0 {
return fmt.Errorf("no remotes confirmed change")
}
if ok < (all/2)+1 {
return fmt.Errorf("quorum not reached")
} }
return nil return nil
} }