Skip to content
Snippets Groups Projects
Commit bd006184 authored by Jono Wenger's avatar Jono Wenger
Browse files

Add ReadyToSend, which checks if the network is ready to send on

parent e6e5bd56
No related branches found
No related tags found
3 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!340Project/channels
......@@ -10,6 +10,7 @@ package bindings
import (
"encoding/json"
"fmt"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/message"
"time"
......@@ -82,6 +83,25 @@ func (c *Cmix) WaitForNetwork(timeoutMS int) bool {
return false
}
// ReadyToSend determines if the network is ready to send messages on. It
// returns true if the network is healthy and if the client has registered with
// at least 70% of the nodes. Returns false otherwise.
func (c *Cmix) ReadyToSend() bool {
// Check if the network is currently healthy
if !c.api.GetCmix().IsHealthy() {
return false
}
// If the network is healthy, then check the number of nodes that the client
// is currently registered with
numReg, total, err := c.api.GetNodeRegistrationStatus()
if err != nil {
jww.FATAL.Panicf("Failed to get node registration status: %+v", err)
}
return numReg >= total*7/10
}
// NetworkFollowerStatus gets the state of the network follower. It returns a
// status with the following values:
// Stopped - 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment