mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.0 KiB
96 lines
2.0 KiB
11 years ago
|
package main
|
||
|
|
||
|
import (
|
||
10 years ago
|
"os"
|
||
|
"runtime"
|
||
|
|
||
10 years ago
|
"github.com/ethereum/go-ethereum"
|
||
|
"github.com/ethereum/go-ethereum/ethlog"
|
||
11 years ago
|
"github.com/ethereum/go-ethereum/utils"
|
||
10 years ago
|
"gopkg.in/qml.v1"
|
||
11 years ago
|
)
|
||
|
|
||
11 years ago
|
const (
|
||
10 years ago
|
ClientIdentifier = "Mist"
|
||
10 years ago
|
Version = "0.7.1"
|
||
11 years ago
|
)
|
||
|
|
||
10 years ago
|
var ethereum *eth.Ethereum
|
||
11 years ago
|
|
||
10 years ago
|
func run() error {
|
||
11 years ago
|
// precedence: code-internal flag default < config file < environment variables < command line
|
||
|
Init() // parsing command line
|
||
11 years ago
|
|
||
10 years ago
|
config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
|
||
11 years ago
|
|
||
|
utils.InitDataDir(Datadir)
|
||
|
|
||
10 years ago
|
stdLog := utils.InitLogging(Datadir, LogFile, LogLevel, DebugFile)
|
||
11 years ago
|
|
||
11 years ago
|
db := utils.NewDatabase()
|
||
10 years ago
|
err := utils.DBSanityCheck(db)
|
||
|
if err != nil {
|
||
|
ErrorWindow(err)
|
||
10 years ago
|
|
||
10 years ago
|
os.Exit(1)
|
||
|
}
|
||
11 years ago
|
|
||
|
keyManager := utils.NewKeyManager(KeyStore, Datadir, db)
|
||
11 years ago
|
|
||
|
// create, import, export keys
|
||
11 years ago
|
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
||
|
|
||
11 years ago
|
clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier)
|
||
|
|
||
10 years ago
|
ethereum = utils.NewEthereum(db, clientIdentity, keyManager, UseUPnP, OutboundPort, MaxPeer)
|
||
11 years ago
|
|
||
11 years ago
|
if ShowGenesis {
|
||
|
utils.ShowGenesis(ethereum)
|
||
|
}
|
||
11 years ago
|
|
||
|
if StartRpc {
|
||
|
utils.StartRpc(ethereum, RpcPort)
|
||
|
}
|
||
|
|
||
11 years ago
|
gui := NewWindow(ethereum, config, clientIdentity, KeyRing, LogLevel)
|
||
10 years ago
|
gui.stdLog = stdLog
|
||
11 years ago
|
|
||
11 years ago
|
utils.RegisterInterrupt(func(os.Signal) {
|
||
11 years ago
|
gui.Stop()
|
||
|
})
|
||
11 years ago
|
utils.StartEthereum(ethereum, UseSeed)
|
||
11 years ago
|
// gui blocks the main thread
|
||
|
gui.Start(AssetPath)
|
||
10 years ago
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||
|
|
||
|
// 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()
|
||
|
|
||
10 years ago
|
if StartWebSockets {
|
||
|
utils.StartWebSockets(ethereum)
|
||
|
}
|
||
|
|
||
11 years ago
|
// we need to run the interrupt callbacks in case gui is closed
|
||
|
// this skips if we got here by actual interrupt stopping the GUI
|
||
11 years ago
|
if !interrupted {
|
||
|
utils.RunInterruptCallbacks(os.Interrupt)
|
||
11 years ago
|
}
|
||
|
// this blocks the thread
|
||
|
ethereum.WaitForShutdown()
|
||
|
ethlog.Flush()
|
||
11 years ago
|
}
|