reorg initialization code for better readability, remove unused import

This commit is contained in:
vyzo 2023-03-30 18:15:13 +03:00
parent 7b4e68249a
commit d71b528253

View File

@ -2,7 +2,6 @@ package vm
import ( import (
"context" "context"
"errors"
"os" "os"
"strconv" "strconv"
"sync" "sync"
@ -154,23 +153,18 @@ func metricsAdjust(metric *stats.Int64Measure, lane ExecutionLane, delta int) {
} }
func init() { func init() {
var available, priority int
var err error var err error
concurrency := os.Getenv("LOTUS_FVM_CONCURRENCY") available := DefaultAvailableExecutionLanes
if concurrency == "" { if concurrency := os.Getenv("LOTUS_FVM_CONCURRENCY"); concurrency != "" {
available = DefaultAvailableExecutionLanes
} else {
available, err = strconv.Atoi(concurrency) available, err = strconv.Atoi(concurrency)
if err != nil { if err != nil {
panic(err) panic(err)
} }
} }
reserved := os.Getenv("LOTUS_FVM_CONCURRENCY_RESERVED") priority := DefaultPriorityExecutionLanes
if reserved == "" { if reserved := os.Getenv("LOTUS_FVM_CONCURRENCY_RESERVED"); reserved != "" {
priority = DefaultPriorityExecutionLanes
} else {
priority, err = strconv.Atoi(reserved) priority, err = strconv.Atoi(reserved)
if err != nil { if err != nil {
panic(err) panic(err)