Skip to content
Snippets Groups Projects
Commit cdf2ab55 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add check for full rounds to sendCmix and retry

parent 72b96798
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"strings"
"time" "time"
) )
...@@ -34,7 +35,7 @@ func (m *Manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, err ...@@ -34,7 +35,7 @@ func (m *Manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, err
} }
remainingTime := param.Timeout - elapsed remainingTime := param.Timeout - elapsed
//find the best round to send to, excluding roudn which have been attempted //find the best round to send to, excluding attempted rounds
bestRound, _ := m.Instance.GetWaitingRounds().GetUpcomingRealtime(remainingTime, attempted) bestRound, _ := m.Instance.GetWaitingRounds().GetUpcomingRealtime(remainingTime, attempted)
//build the topology //build the topology
...@@ -95,19 +96,25 @@ func (m *Manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, err ...@@ -95,19 +96,25 @@ func (m *Manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, err
//Add the mac proving ownership //Add the mac proving ownership
msg.MAC = roundKeys.MakeClientGatewayKey(salt, network.GenerateSlotDigest(msg)) msg.MAC = roundKeys.MakeClientGatewayKey(salt, network.GenerateSlotDigest(msg))
//add the round on to the list of attempted so it is not tried again
attempted.Insert(bestRound)
//Send the payload //Send the payload
gwSlotResp, err := m.Comms.SendPutMessage(transmitGateway, msg) gwSlotResp, err := m.Comms.SendPutMessage(transmitGateway, msg)
//if the comm errors or the message fails to send, continue retrying. //if the comm errors or the message fails to send, continue retrying.
//return if it sends properly //return if it sends properly
if err != nil { if err != nil {
if strings.Contains(err.Error(),
"try a different round.") {
jww.WARN.Printf("could not send: %s",
err)
continue
}
jww.ERROR.Printf("Failed to send message to %s: %s", jww.ERROR.Printf("Failed to send message to %s: %s",
transmitGateway, err) transmitGateway, err)
} else if gwSlotResp.Accepted { } else if gwSlotResp.Accepted {
return id.Round(bestRound.ID), nil return id.Round(bestRound.ID), nil
} }
//add the round on to the list of attempted so it is not tried again
attempted.Insert(bestRound)
} }
return 0, errors.New("failed to send the message") return 0, errors.New("failed to send the message")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment