From 04e6659a61f9372fb4a0dc7975a2b9cf85353d31 Mon Sep 17 00:00:00 2001 From: Rafal Leszko Date: Wed, 23 Feb 2022 10:49:54 +0100 Subject: [PATCH] cmd: Add setupOrchestrator() to Redeemer mode --- cmd/livepeer/livepeer.go | 12 +++++++----- cmd/livepeer/livepeer_test.go | 5 ++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/livepeer/livepeer.go b/cmd/livepeer/livepeer.go index 842d985e1..8ca5a35a7 100644 --- a/cmd/livepeer/livepeer.go +++ b/cmd/livepeer/livepeer.go @@ -635,10 +635,7 @@ func main() { return } - orchSetupCtx, cancel := context.WithCancel(ctx) - defer cancel() - - if err := setupOrchestrator(orchSetupCtx, n, recipientAddr); err != nil { + if err := setupOrchestrator(n, recipientAddr); err != nil { glog.Errorf("Error setting up orchestrator: %v", err) return } @@ -721,6 +718,11 @@ func main() { } if n.NodeType == core.RedeemerNode { + if err := setupOrchestrator(n, recipientAddr); err != nil { + glog.Errorf("Error setting up orchestrator: %v", err) + return + } + r, err := server.NewRedeemer( recipientAddr, n.Eth, @@ -1173,7 +1175,7 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) { return ethUri, nil } -func setupOrchestrator(ctx context.Context, n *core.LivepeerNode, ethOrchAddr ethcommon.Address) error { +func setupOrchestrator(n *core.LivepeerNode, ethOrchAddr ethcommon.Address) error { // add orchestrator to DB orch, err := n.Eth.GetTranscoder(ethOrchAddr) if err != nil { diff --git a/cmd/livepeer/livepeer_test.go b/cmd/livepeer/livepeer_test.go index 6c61c732d..264362a43 100644 --- a/cmd/livepeer/livepeer_test.go +++ b/cmd/livepeer/livepeer_test.go @@ -1,7 +1,6 @@ package main import ( - "context" "errors" "math/big" "testing" @@ -40,7 +39,7 @@ func TestSetupOrchestrator(t *testing.T) { n, err := core.NewLivepeerNode(stubEthClient, "", dbh) require.Nil(err) - err = setupOrchestrator(context.Background(), n, orch) + err = setupOrchestrator(n, orch) assert.Nil(err) orchs, err := dbh.SelectOrchs(&common.DBOrchFilter{ @@ -53,7 +52,7 @@ func TestSetupOrchestrator(t *testing.T) { // test eth.GetTranscoder error stubEthClient.Err = errors.New("GetTranscoder error") - err = setupOrchestrator(context.Background(), n, orch) + err = setupOrchestrator(n, orch) assert.EqualError(err, "GetTranscoder error") }