Skip to content
Snippets Groups Projects
Commit 401070a2 authored by ksparakis's avatar ksparakis
Browse files

fix poll ndf logic to loop till it gets the ndf

parent c5f2e153
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ package notifications ...@@ -10,6 +10,7 @@ package notifications
import ( import (
"crypto/sha256" "crypto/sha256"
"fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/comms/connect" "gitlab.com/elixxir/comms/connect"
...@@ -17,6 +18,7 @@ import ( ...@@ -17,6 +18,7 @@ import (
"gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/ndf" "gitlab.com/elixxir/primitives/ndf"
"strings" "strings"
"time"
) )
// We use an interface here inorder to allow us to mock the getHost and RequestNDF in the notifcationsBot.Comms for testing // We use an interface here inorder to allow us to mock the getHost and RequestNDF in the notifcationsBot.Comms for testing
...@@ -44,11 +46,13 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms notificationComms) (*ndf.N ...@@ -44,11 +46,13 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms notificationComms) (*ndf.N
//Send the hash to registration //Send the hash to registration
response, err := comms.RequestNdf(regHost, msg) response, err := comms.RequestNdf(regHost, msg)
if err != nil { if err != nil {
errMsg := errors.Errorf("Failed to get ndf from permissioning: %v", err) for err != nil && strings.Contains(err.Error(), ndf.NO_NDF) {
if strings.Contains(errMsg.Error(), ndf.NO_NDF) { jww.WARN.Println("Failed to get an ndf, possibly not ready yet. Retying now...")
jww.WARN.Println("Continuing without an updated NDF") time.Sleep(50*time.Millisecond)
return nil, nil response, err = comms.RequestNdf(regHost, msg)
} }
// If it is not an issue with no ndf, return the error up the stack
errMsg := errors.Errorf("Failed to get ndf from permissioning: %v", err)
return nil, errMsg return nil, errMsg
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment