Skip to content

Commit

Permalink
Merge branch 'main' into PRT-191-reindent-specs-for-better-readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Dec 22, 2022
2 parents 551d28b + a94e19a commit 81faf64
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 88 deletions.
19 changes: 14 additions & 5 deletions relayer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,13 @@ func (s *relayServer) initRelay(ctx context.Context, request *pairingtypes.Relay
}

// Checks
if g_sentry.Acc != request.Provider {
return nil, nil, nil, nil, utils.LavaFormatError("User is trying to communicate with the wrong provider address.", nil, &map[string]string{
"ProviderWhoGotTheRequest": g_sentry.Acc,
"ProviderInTheRequest": request.Provider,
})
}

user, err := getRelayUser(request)
if err != nil {
return nil, nil, nil, nil, utils.LavaFormatError("get relay user", err, &map[string]string{})
Expand Down Expand Up @@ -1238,11 +1245,6 @@ func Server(

pairingtypes.RegisterRelayerServer(s, Server)

utils.LavaFormatInfo("Server listening", &map[string]string{"Address": lis.Addr().String()})
if err := httpServer.Serve(lis); !errors.Is(err, http.ErrServerClosed) {
utils.LavaFormatFatal("provider failed to serve", err, &map[string]string{"Address": lis.Addr().String(), "ChainID": chainID})
}

cacheAddr, err := flagSet.GetString(performance.CacheFlagName)
if err != nil {
utils.LavaFormatError("Failed To Get Cache Address flag", err, &map[string]string{"flags": fmt.Sprintf("%v", flagSet)})
Expand All @@ -1255,5 +1257,12 @@ func Server(
chainProxy.SetCache(cache)
}
}

utils.LavaFormatInfo("Server listening", &map[string]string{"Address": lis.Addr().String()})
// serve is blocking, until terminated
if err := httpServer.Serve(lis); !errors.Is(err, http.ErrServerClosed) {
utils.LavaFormatFatal("provider failed to serve", err, &map[string]string{"Address": lis.Addr().String(), "ChainID": chainID})
}
// in case we stop serving, claim rewards
askForRewards(int64(g_sentry.GetCurrentEpochHeight()))
}
Loading

0 comments on commit 81faf64

Please sign in to comment.