Skip to content

Commit 2e0200e

Browse files
committed
Update healthcheck data message
1 parent f62beae commit 2e0200e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pkg/mpc/registry.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ func (r *registry) Ready() error {
159159
}
160160

161161
_, err = r.healthCheck.Listen(r.composeHealthCheckTopic(r.nodeID), func(data []byte) {
162-
peerID, ecdhReadyPeersCount, _ := parseHealthDataSplit(string(data))
162+
peerID, isEcdhReady, _ := parseHealthDataSplit(string(data))
163163
logger.Debug("Health check ok", "peerID", peerID)
164-
if ecdhReadyPeersCount < int(r.GetReadyPeersCountExcludeSelf()) {
164+
if !isEcdhReady {
165165
logger.Info("[ECDH exchange retriggerd] not all peers are ready", "peerID", peerID)
166166
go r.triggerECDHExchange()
167167

@@ -356,20 +356,20 @@ func (r *registry) composeHealthCheckTopic(nodeID string) string {
356356
}
357357

358358
func (r *registry) composeHealthData() string {
359-
return fmt.Sprintf("%s,%d", r.nodeID, r.ecdhSession.GetReadyPeersCount())
359+
isECDHReady := r.isECDHReady()
360+
return fmt.Sprintf("%s,%t", r.nodeID, isECDHReady)
360361
}
361362

362-
func parseHealthDataSplit(s string) (peerID string, readyCount int, err error) {
363+
func parseHealthDataSplit(s string) (peerID string, ready bool, err error) {
363364
parts := strings.SplitN(s, ",", 2)
364365
if len(parts) != 2 {
365-
return "", 0, fmt.Errorf("invalid format: %q", s)
366+
return "", false, fmt.Errorf("invalid format: %q", s)
366367
}
367368

368369
peerID = parts[0]
369-
readyCount, err = strconv.Atoi(parts[1])
370+
ready, err = strconv.ParseBool(parts[1]) // accepts "true"/"false", "1"/"0", "t"/"f"
370371
if err != nil {
371-
return "", 0, err
372+
return "", false, err
372373
}
373-
return peerID, readyCount, nil
374-
374+
return peerID, ready, nil
375375
}

0 commit comments

Comments
 (0)