aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ethereum.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-06-23 19:20:59 +0800
committerzelig <viktor.tron@gmail.com>2014-06-23 19:25:55 +0800
commit1024766514eea7bb628ec6e5ed974e997b8faefc (patch)
tree01b5846bd852822538e5010fe0c6116c6de900ea /ethereal/ethereum.go
parent456167aca0b795c625d6718ef8a06fe5fcb00c2e (diff)
downloaddexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar.gz
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar.bz2
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar.lz
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar.xz
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.tar.zst
dexon-1024766514eea7bb628ec6e5ed974e997b8faefc.zip
refactor cli and gui wrapper code. Details:
- all cli functions shared between ethereum and ethereal abstracted to utils/ cmd.go (should be ethcommon or shared or sth) - simplify main() now readable stepwise - rename main wrapper files to main.go - rename commmand line args definition file from config.go to flags.go - rename Do -> Start to parallel option names - register interrupt for rpc server stop - fix interrupt stopping js repl and ethereum - register interrupt for mining stop - custom config file option from command line - debug option from command line - loglevel option from command line - changed ethutil.Config API - default datadir and default config file set together with other flag defaults in wrappers - default assetpath set together with other command line flags defaults in gui wrapper (not in ethutil.Config or ui/ui_lib) - options precedence: default < config file < environment variables < command line
Diffstat (limited to 'ethereal/ethereum.go')
-rw-r--r--ethereal/ethereum.go142
1 files changed, 0 insertions, 142 deletions
diff --git a/ethereal/ethereum.go b/ethereal/ethereum.go
deleted file mode 100644
index 0db1fa4cd..000000000
--- a/ethereal/ethereum.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package main
-
-import (
- "fmt"
- "github.com/ethereum/eth-go"
- "github.com/ethereum/eth-go/ethutil"
- "github.com/ethereum/go-ethereum/ethereal/ui"
- "github.com/ethereum/go-ethereum/utils"
- "github.com/go-qml/qml"
- "github.com/rakyll/globalconf"
- "log"
- "os"
- "os/signal"
- "path"
- "runtime"
-)
-
-const Debug = true
-
-// Register interrupt handlers so we can stop the ethereum
-func RegisterInterupts(s *eth.Ethereum) {
- // Buffered chan of one is enough
- c := make(chan os.Signal, 1)
- // Notify about interrupts for now
- signal.Notify(c, os.Interrupt)
- go func() {
- for sig := range c {
- fmt.Printf("Shutting down (%v) ... \n", sig)
-
- s.Stop()
- }
- }()
-}
-
-func main() {
- Init()
-
- qml.Init(nil)
-
- runtime.GOMAXPROCS(runtime.NumCPU())
-
- g, err := globalconf.NewWithOptions(&globalconf.Options{
- Filename: path.Join(ethutil.ApplicationFolder(Datadir), "conf.ini"),
- })
- if err != nil {
- fmt.Println(err)
- } else {
- g.ParseAll()
- }
- ethutil.ReadConfig(Datadir, ethutil.LogFile|ethutil.LogStd, g, Identifier)
-
- // Instantiated a eth stack
- ethereum, err := eth.New(eth.CapDefault, UseUPnP)
- if err != nil {
- log.Println("eth start err:", err)
- return
- }
- ethereum.Port = OutboundPort
-
- if GenAddr {
- fmt.Println("This action overwrites your old private key. Are you sure? (y/n)")
-
- var r string
- fmt.Scanln(&r)
- for ; ; fmt.Scanln(&r) {
- if r == "n" || r == "y" {
- break
- } else {
- fmt.Printf("Yes or no?", r)
- }
- }
-
- if r == "y" {
- utils.CreateKeyPair(true)
- }
- os.Exit(0)
- } else {
- if len(ImportKey) > 0 {
- fmt.Println("This action overwrites your old private key. Are you sure? (y/n)")
- var r string
- fmt.Scanln(&r)
- for ; ; fmt.Scanln(&r) {
- if r == "n" || r == "y" {
- break
- } else {
- fmt.Printf("Yes or no?", r)
- }
- }
-
- if r == "y" {
- utils.ImportPrivateKey(ImportKey)
- os.Exit(0)
- }
- }
- }
-
- if ExportKey {
- keyPair := ethutil.GetKeyRing().Get(0)
- fmt.Printf(`
-Generating new address and keypair.
-Please keep your keys somewhere save.
-
-++++++++++++++++ KeyRing +++++++++++++++++++
-addr: %x
-prvk: %x
-pubk: %x
-++++++++++++++++++++++++++++++++++++++++++++
-save these words so you can restore your account later: %s
-`, keyPair.Address(), keyPair.PrivateKey, keyPair.PublicKey)
-
- os.Exit(0)
- }
-
- if ShowGenesis {
- fmt.Println(ethereum.BlockChain().Genesis())
- os.Exit(0)
- }
-
- /*
- if StartMining {
- utils.DoMining(ethereum)
- }
- */
-
- if StartRpc {
- utils.DoRpc(ethereum, RpcPort)
- }
-
- log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver)
-
- // Set the max peers
- ethereum.MaxPeers = MaxPeer
-
- gui := ethui.New(ethereum)
-
- ethereum.Start(UseSeed)
-
- gui.Start(AssetPath)
-
- // Wait for shutdown
- ethereum.WaitForShutdown()
-}