From e8e71e3e220295b7d37901fb23702a518578f0a8 Mon Sep 17 00:00:00 2001
From: benjamin <ben@elixxir.io>
Date: Fri, 21 Oct 2022 16:07:41 -0700
Subject: [PATCH] made the channels system set messages as failed when their
 rounds fail

---
 channels/sendTracker.go | 23 +++++++++++------------
 cmix/nodes/request.go   |  2 +-
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/channels/sendTracker.go b/channels/sendTracker.go
index 023785fa7..437340a51 100644
--- a/channels/sendTracker.go
+++ b/channels/sendTracker.go
@@ -106,7 +106,7 @@ func loadSendTracker(net Client, kv *versioned.KV, trigger triggerEventFunc,
 	st.unsent = make(map[uint64]*tracked)
 
 	//register to check all outstanding rounds when the network becomes healthy
-	/*var callBackID uint64
+	var callBackID uint64
 	callBackID = net.AddHealthCallback(func(f bool) {
 		if !f {
 			return
@@ -120,7 +120,7 @@ func loadSendTracker(net Client, kv *versioned.KV, trigger triggerEventFunc,
 			}
 			st.net.GetRoundResults(getRoundResultsTimeout, rr.callback, rr.round)
 		}
-	})*/
+	})
 
 	return st
 }
@@ -337,19 +337,19 @@ func (st *sendTracker) handleSend(uuid uint64,
 	t.RoundID = round.ID
 
 	//add the roundID
-	roundsList, _ := st.byRound[round.ID]
+	roundsList, existsRound := st.byRound[round.ID]
 	st.byRound[round.ID] = append(roundsList, t)
 
 	//add the round
 	st.byMessageID[messageID] = t
 
-	/*if !existsRound {
+	if !existsRound {
 		rr := &roundResults{
 			round: round.ID,
 			st:    st,
 		}
 		st.net.GetRoundResults(getRoundResultsTimeout, rr.callback, rr.round)
-	}*/
+	}
 
 	delete(st.unsent, uuid)
 
@@ -486,12 +486,11 @@ func (rr *roundResults) callback(allRoundsSucceeded, timedOut bool, results map[
 	}
 
 	rr.st.mux.Unlock()
-
-	for i := range registered {
-		round := results[rr.round].Round
-		ts := mutateTimestamp(round.Timestamps[states.QUEUED], registered[i].MsgID)
-		go rr.st.updateStatus(registered[i].UUID, registered[i].MsgID, ts,
-			round, status)
+	if status == Failed {
+		for i := range registered {
+			round := results[rr.round].Round
+			go rr.st.updateStatus(registered[i].UUID, registered[i].MsgID, time.Time{},
+				round, Failed)
+		}
 	}
-
 }
diff --git a/cmix/nodes/request.go b/cmix/nodes/request.go
index 978cd01a3..abee1dfff 100644
--- a/cmix/nodes/request.go
+++ b/cmix/nodes/request.go
@@ -199,7 +199,7 @@ func processRequestResponse(signedKeyResponse *pb.SignedKeyResponse,
 	sessionKey := registration.GenerateBaseKey(grp,
 		nodeDHPub, dhPrivKey, h)
 
-	jww.INFO.Printf("DH for reg took %s", time.Since(start))
+	jww.TRACE.Printf("DH for reg took %s", time.Since(start))
 
 	// Verify the HMAC
 	if !registration.VerifyClientHMAC(sessionKey.Bytes(),
-- 
GitLab