Skip to content

Commit

Permalink
feat: remove -pricePerUnit requirement for -aiWorker flag (livepeer#3047
Browse files Browse the repository at this point in the history
)

* Remove -pricePerUnit requirement for orchestrator with -AIWorker flag

* refactor: add PricePerUnit comment

This commit reintroduces the previously omitted comment for the
PricePerUnit variable, improving code readability and maintainability.

* refactor: simplify PricePerUnit flag check condition

This commit simplifies the conditional check used to check if the
`PricePerUnit` flag is needed.

---------

Co-authored-by: Rick Staa <[email protected]>
  • Loading branch information
eliteprox and rickstaa committed Jul 26, 2024
1 parent 1477aa8 commit 8b69818
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cmd/livepeer/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,19 +879,17 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {

if *cfg.Orchestrator {
// Set price per pixel base info
if *cfg.PixelsPerUnit <= 0 {
// Can't divide by 0
panic(fmt.Errorf("-pixelsPerUnit must be > 0, provided %d", *cfg.PixelsPerUnit))
}
if cfg.PricePerUnit == nil {
if cfg.PricePerUnit == nil && !*cfg.AIWorker {
// Prevent orchestrators from unknowingly providing free transcoding
panic(fmt.Errorf("-pricePerUnit must be set"))
} else if cfg.PricePerUnit != nil {
if *cfg.PricePerUnit < 0 {
panic(fmt.Errorf("-pricePerUnit must be >= 0, provided %d", *cfg.PricePerUnit))
}

n.SetBasePrice("default", big.NewRat(int64(*cfg.PricePerUnit), int64(*cfg.PixelsPerUnit)))
glog.Infof("Price: %d wei for %d pixels\n ", *cfg.PricePerUnit, *cfg.PixelsPerUnit)
}
if *cfg.PricePerUnit < 0 {
panic(fmt.Errorf("-pricePerUnit must be >= 0, provided %d", *cfg.PricePerUnit))
}
n.SetBasePrice("default", big.NewRat(int64(*cfg.PricePerUnit), int64(*cfg.PixelsPerUnit)))
glog.Infof("Price: %d wei for %d pixels\n ", *cfg.PricePerUnit, *cfg.PixelsPerUnit)

if *cfg.PricePerBroadcaster != "" {
ppb := getBroadcasterPrices(*cfg.PricePerBroadcaster)
Expand Down

0 comments on commit 8b69818

Please sign in to comment.