/
init.go
47 lines (39 loc) · 1.36 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package executor
import (
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
workerCommon "github.com/oasisprotocol/oasis-core/go/worker/common"
"github.com/oasisprotocol/oasis-core/go/worker/compute"
"github.com/oasisprotocol/oasis-core/go/worker/registration"
)
const (
// CfgScheduleCheckTxEnabled enables checking each transaction before
// scheduling it.
CfgScheduleCheckTxEnabled = "worker.executor.schedule_check_tx.enabled"
cfgMaxQueueSize = "worker.executor.schedule_max_queue_size"
cfgScheduleTxCacheSize = "worker.executor.schedule_tx_cache_size"
)
// Flags has the configuration flags.
var Flags = flag.NewFlagSet("", flag.ContinueOnError)
// New creates a new executor worker.
func New(
dataDir string,
commonWorker *workerCommon.Worker,
registration *registration.Worker,
) (*Worker, error) {
return newWorker(
dataDir,
compute.Enabled(),
commonWorker,
registration,
viper.GetBool(CfgScheduleCheckTxEnabled),
viper.GetUint64(cfgMaxQueueSize),
viper.GetUint64(cfgScheduleTxCacheSize),
)
}
func init() {
Flags.Bool(CfgScheduleCheckTxEnabled, false, "Enable checking transactions before scheduling them")
Flags.Uint64(cfgMaxQueueSize, 10000, "Maximum size of the scheduling queue")
Flags.Uint64(cfgScheduleTxCacheSize, 1000, "Cache size of recently scheduled transactions to prevent re-scheduling")
_ = viper.BindPFlags(Flags)
}