aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/main.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-10 06:03:20 +0800
committerFelix Lange <fjl@twurst.com>2015-03-10 06:08:47 +0800
commit697f6748b8df6b50157f81eb7959d856d3eb688e (patch)
tree1ddcff1433ce9f6fdb0024abeba70da162949821 /cmd/mist/main.go
parentc2e5dacf555d93cb96b8fbffa700a2a6fece8bf0 (diff)
downloaddexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar.gz
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar.bz2
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar.lz
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar.xz
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.tar.zst
dexon-697f6748b8df6b50157f81eb7959d856d3eb688e.zip
cmd/mist: use cli library and package accounts
Diffstat (limited to 'cmd/mist/main.go')
-rw-r--r--cmd/mist/main.go101
1 files changed, 49 insertions, 52 deletions
diff --git a/cmd/mist/main.go b/cmd/mist/main.go
index 1d4403848..425630ece 100644
--- a/cmd/mist/main.go
+++ b/cmd/mist/main.go
@@ -26,10 +26,10 @@ import (
"runtime"
"time"
+ "github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/ui/qt/webengine"
"github.com/obscuren/qml"
)
@@ -39,56 +39,32 @@ const (
Version = "0.8.6"
)
-var ethereum *eth.Ethereum
-var mainlogger = logger.NewLogger("MAIN")
-
-func run() error {
- webengine.Initialize()
-
- // precedence: code-internal flag default < config file < environment variables < command line
- Init() // parsing command line
-
- tstart := time.Now()
- config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
-
- ethereum, err := eth.New(&eth.Config{
- Name: p2p.MakeName(ClientIdentifier, Version),
- KeyStore: KeyStore,
- DataDir: Datadir,
- LogFile: LogFile,
- LogLevel: LogLevel,
- MaxPeers: MaxPeer,
- Port: OutboundPort,
- NAT: NAT,
- Shh: true,
- BootNodes: BootNodes,
- NodeKey: NodeKey,
- KeyRing: KeyRing,
- Dial: true,
- MinerThreads: MinerThreads,
- })
- if err != nil {
- mainlogger.Fatalln(err)
+var (
+ app = utils.NewApp(Version, "the ether browser")
+ assetPathFlag = cli.StringFlag{
+ Name: "asset_path",
+ Usage: "absolute path to GUI assets directory",
+ Value: ethutil.DefaultAssetPath(),
}
- utils.KeyTasks(ethereum.KeyManager(), KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
+)
- if StartRpc {
- utils.StartRpc(ethereum, RpcListenAddress, RpcPort)
+func init() {
+ app.Action = run
+ app.Flags = []cli.Flag{
+ assetPathFlag,
+
+ utils.BootnodesFlag,
+ utils.DataDirFlag,
+ utils.ListenPortFlag,
+ utils.LogFileFlag,
+ utils.LogLevelFlag,
+ utils.MaxPeersFlag,
+ utils.MinerThreadsFlag,
+ utils.NATFlag,
+ utils.NodeKeyFileFlag,
+ utils.RPCListenAddrFlag,
+ utils.RPCPortFlag,
}
-
- gui := NewWindow(ethereum, config, KeyRing, LogLevel)
-
- utils.RegisterInterrupt(func(os.Signal) {
- gui.Stop()
- })
- go utils.StartEthereum(ethereum)
-
- fmt.Println("ETH stack took", time.Since(tstart))
-
- // gui blocks the main thread
- gui.Start(AssetPath)
-
- return nil
}
func main() {
@@ -97,15 +73,16 @@ func main() {
// This is a bit of a cheat, but ey!
os.Setenv("QTWEBKIT_INSPECTOR_SERVER", "127.0.0.1:99999")
- qml.Run(run)
-
var interrupted = false
utils.RegisterInterrupt(func(os.Signal) {
interrupted = true
})
-
utils.HandleInterrupt()
+ if err := app.Run(os.Args); err != nil {
+ fmt.Fprintln(os.Stderr, "Error: ", err)
+ }
+
// we need to run the interrupt callbacks in case gui is closed
// this skips if we got here by actual interrupt stopping the GUI
if !interrupted {
@@ -113,3 +90,23 @@ func main() {
}
logger.Flush()
}
+
+func run(ctx *cli.Context) {
+ tstart := time.Now()
+
+ // TODO: show qml popup instead of exiting if initialization fails.
+ ethereum := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ utils.StartRPC(ethereum, ctx)
+ go utils.StartEthereum(ethereum)
+ fmt.Println("initializing eth stack took", time.Since(tstart))
+
+ // Open the window
+ qml.Run(func() error {
+ webengine.Initialize()
+ gui := NewWindow(ethereum)
+ utils.RegisterInterrupt(func(os.Signal) { gui.Stop() })
+ // gui blocks the main thread
+ gui.Start(ctx.GlobalString(assetPathFlag.Name))
+ return nil
+ })
+}