mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
// (c) 2022, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"github.com/luxfi/evm/cmd/simulator/config"
|
|
"github.com/luxfi/evm/cmd/simulator/load"
|
|
"github.com/luxfi/log"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
func main() {
|
|
fs := config.BuildFlagSet()
|
|
v, err := config.BuildViper(fs, os.Args[1:])
|
|
if errors.Is(err, pflag.ErrHelp) {
|
|
os.Exit(0)
|
|
}
|
|
|
|
if err != nil {
|
|
fmt.Printf("couldn't build viper: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err != nil {
|
|
fmt.Printf("couldn't configure flags: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if v.GetBool(config.VersionKey) {
|
|
fmt.Printf("%s\n", config.Version)
|
|
os.Exit(0)
|
|
}
|
|
|
|
// Set up logging
|
|
logLevel := v.GetString(config.LogLevelKey)
|
|
// Set up logging using the geth log package
|
|
log.SetDefault(log.NewLogger("simulator"))
|
|
// TODO: Apply log level from config
|
|
_ = logLevel
|
|
|
|
config, err := config.BuildConfig(v)
|
|
if err != nil {
|
|
fmt.Printf("%s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
if err := load.ExecuteLoader(context.Background(), config); err != nil {
|
|
fmt.Printf("load execution failed: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|