Skip to content

Commit

Permalink
cmd: Add setupOrchestrator() to Redeemer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Feb 24, 2022
1 parent faeb96e commit 04e6659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 7 additions & 5 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions cmd/livepeer/livepeer_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"context"
"errors"
"math/big"
"testing"
Expand Down Expand Up @@ -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{
Expand All @@ -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")
}

Expand Down

0 comments on commit 04e6659

Please sign in to comment.