diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-19 22:32:45 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-19 22:32:45 +0800 |
commit | 017bbbb582b09a3264b4ff996f35275d381f284f (patch) | |
tree | b11fba658b414029b78958ddb6137634e7ccf966 /ethereum/ethereum.go | |
parent | 16421106d47efb65331ed9f0499f12038158cbf1 (diff) | |
download | go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar.gz go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar.bz2 go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar.lz go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar.xz go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.tar.zst go-tangerine-017bbbb582b09a3264b4ff996f35275d381f284f.zip |
Improved REPL output
Diffstat (limited to 'ethereum/ethereum.go')
-rw-r--r-- | ethereum/ethereum.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ethereum/ethereum.go b/ethereum/ethereum.go index 04933ef8e..1cbb61002 100644 --- a/ethereum/ethereum.go +++ b/ethereum/ethereum.go @@ -15,16 +15,15 @@ import ( const Debug = true -// Register interrupt handlers so we can stop the ethereum -func RegisterInterrupts(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) +func RegisterInterrupt(cb func(os.Signal)) { go func() { + // Buffered chan of one is enough + c := make(chan os.Signal, 1) + // Notify about interrupts for now + signal.Notify(c, os.Interrupt) + for sig := range c { - fmt.Printf("Shutting down (%v) ... \n", sig) - s.Stop() + cb(sig) } }() } @@ -154,13 +153,20 @@ save these words so you can restore your account later: %s repl := NewJSRepl(ethereum) go repl.Start() + + RegisterInterrupt(func(os.Signal) { + repl.Stop() + }) } if StartRpc { utils.DoRpc(ethereum, RpcPort) } - RegisterInterrupts(ethereum) + RegisterInterrupt(func(sig os.Signal) { + fmt.Printf("Shutting down (%v) ... \n", sig) + ethereum.Stop() + }) ethereum.Start(UseSeed) |