From 0fa85a860b970124329a6747c89c24352775c964 Mon Sep 17 00:00:00 2001
From: Benjamin Wenger <ben@elixxir.ioo>
Date: Wed, 9 Jun 2021 20:37:31 -0700
Subject: [PATCH] made stop and start network follower return well formed
 errors when called while the follower is not in the correct status.

---
 api/client.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/api/client.go b/api/client.go
index c7ac8212b..76da7b654 100644
--- a/api/client.go
+++ b/api/client.go
@@ -392,6 +392,11 @@ func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces.
 	jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s "+
 		"\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID)
 
+	if c.status.get() != Stopping{
+		return nil, errors.Errorf("Cannot Start the Network Follower when it is not stopped")
+	}
+
+
 	c.clientErrorChannel = make(chan interfaces.ClientError, 1000)
 
 	cer := func(source, message, trace string) {
@@ -450,6 +455,11 @@ func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces.
 func (c *Client) StopNetworkFollower() error {
 	c.followerLock.Lock()
 	defer c.followerLock.Unlock()
+
+	if c.status.get() != Running{
+		return errors.Errorf("Cannot Stop the Network Follower when it is not running")
+	}
+
 	err := c.status.toStopping()
 	if err != nil {
 		return errors.WithMessage(err, "Failed to Stop the Network Follower")
-- 
GitLab