From 75615ac21e325f991a8b57522b3d74eca0be7234 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Mon, 7 Jun 2021 08:35:01 -0700 Subject: [PATCH] Use storage to make sure forced retry is not done --- network/rounds/manager.go | 2 -- network/rounds/retrieve.go | 41 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/network/rounds/manager.go b/network/rounds/manager.go index b429201f4..4c1ec87a9 100644 --- a/network/rounds/manager.go +++ b/network/rounds/manager.go @@ -14,7 +14,6 @@ import ( "gitlab.com/elixxir/client/network/internal" "gitlab.com/elixxir/client/network/message" "gitlab.com/elixxir/client/stoppable" - "sync" ) type Manager struct { @@ -24,7 +23,6 @@ type Manager struct { historicalRounds chan historicalRoundRequest lookupRoundMessages chan roundLookup - lookupRetryTracker sync.Map messageBundles chan<- message.Bundle } diff --git a/network/rounds/retrieve.go b/network/rounds/retrieve.go index 46c1b6d1d..adb4e7c51 100644 --- a/network/rounds/retrieve.go +++ b/network/rounds/retrieve.go @@ -83,16 +83,13 @@ func (m *Manager) processMessageRetrieval(comms messageRetrievalComms, // randomly not picking up messages (FOR INTEGRATION TEST). Only done if // round has not been ignored before var bundle message.Bundle - _, ok := m.lookupRetryTracker.Load(ri.ID) - jww.INFO.Printf("After adding round %d to tracker entry is %v", ri.ID, ok) - if !ok && m.params.ForceMessagePickupRetry { + if m.params.ForceMessagePickupRetry { bundle, err = m.forceMessagePickupRetry(ri, rl, comms, gwIds) if err != nil { jww.ERROR.Printf("Failed to get pickup round %d "+ "from all gateways (%v): %s", id.Round(ri.ID), gwIds, err) } - m.lookupRetryTracker.Store(ri.ID, struct{}{}) } else { // Attempt to request for this gateway bundle, err = m.getMessagesFromGateway(id.Round(ri.ID), rl.identity, comms, gwIds) @@ -197,24 +194,26 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round, identity reception.Id // not looking up messages func (m *Manager) forceMessagePickupRetry(ri *pb.RoundInfo, rl roundLookup, comms messageRetrievalComms, gwIds []*id.ID) (bundle message.Bundle, err error) { - // Flip a coin to determine whether to pick up message - stream := m.Rng.GetStream() - defer stream.Close() - b := make([]byte, 8) - _, err = stream.Read(b) - if err != nil { - jww.FATAL.Panic(err.Error()) - } - result := binary.BigEndian.Uint64(b) - jww.INFO.Printf("*** Random result: %d", result) - if result%2 == 0 { - jww.INFO.Printf("Forcing a message pickup retry for round %d", ri.ID) - // Do not call get message, leaving the round to be picked up - // in unchecked round scheduler process - return - } - + _, ok := m.Session.UncheckedRounds().GetRound(id.Round(ri.ID)) + if !ok { + // Flip a coin to determine whether to pick up message + stream := m.Rng.GetStream() + defer stream.Close() + b := make([]byte, 8) + _, err = stream.Read(b) + if err != nil { + jww.FATAL.Panic(err.Error()) + } + result := binary.BigEndian.Uint64(b) + jww.INFO.Printf("*** Random result: %d", result) + if result%2 == 0 { + jww.INFO.Printf("Forcing a message pickup retry for round %d", ri.ID) + // Do not call get message, leaving the round to be picked up + // in unchecked round scheduler process + return + } + } // Attempt to request for this gateway return m.getMessagesFromGateway(id.Round(ri.ID), rl.identity, comms, gwIds) } -- GitLab