diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-20 23:09:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-20 23:09:44 +0800 |
commit | 4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0 (patch) | |
tree | d4622ae52bcc4c158aa26cf171a306979307bfc9 /ethutil | |
parent | 6efdd21633c1d21f36080754a89ad82c0c244128 (diff) | |
parent | c37b3cef7dc465832761b1da6761eeaa47e368d1 (diff) | |
download | go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar.gz go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar.bz2 go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar.lz go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar.xz go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.tar.zst go-tangerine-4b13f93a3e0f2901a8e1aa38dfef115e24c63ef0.zip |
Merge branch 'release/poc5-rc7'
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/common.go | 26 | ||||
-rw-r--r-- | ethutil/common_test.go | 6 | ||||
-rw-r--r-- | ethutil/config.go | 27 | ||||
-rw-r--r-- | ethutil/reactor.go | 3 |
4 files changed, 33 insertions, 29 deletions
diff --git a/ethutil/common.go b/ethutil/common.go index 983ea5d1b..771dfc723 100644 --- a/ethutil/common.go +++ b/ethutil/common.go @@ -7,13 +7,13 @@ import ( // The different number of units var ( - Ether = BigPow(10, 18) - Finney = BigPow(10, 15) - Szabo = BigPow(10, 12) - Vita = BigPow(10, 9) - Turing = BigPow(10, 6) - Eins = BigPow(10, 3) - Wei = big.NewInt(1) + Ether = BigPow(10, 18) + Finney = BigPow(10, 15) + Szabo = BigPow(10, 12) + Shannon = BigPow(10, 9) + Babbage = BigPow(10, 6) + Ada = BigPow(10, 3) + Wei = big.NewInt(1) ) // Currency to string @@ -27,12 +27,12 @@ func CurrencyToString(num *big.Int) string { return fmt.Sprintf("%v Finney", new(big.Int).Div(num, Finney)) case num.Cmp(Szabo) >= 0: return fmt.Sprintf("%v Szabo", new(big.Int).Div(num, Szabo)) - case num.Cmp(Vita) >= 0: - return fmt.Sprintf("%v Vita", new(big.Int).Div(num, Vita)) - case num.Cmp(Turing) >= 0: - return fmt.Sprintf("%v Turing", new(big.Int).Div(num, Turing)) - case num.Cmp(Eins) >= 0: - return fmt.Sprintf("%v Eins", new(big.Int).Div(num, Eins)) + case num.Cmp(Shannon) >= 0: + return fmt.Sprintf("%v Shannon", new(big.Int).Div(num, Shannon)) + case num.Cmp(Babbage) >= 0: + return fmt.Sprintf("%v Babbage", new(big.Int).Div(num, Babbage)) + case num.Cmp(Ada) >= 0: + return fmt.Sprintf("%v Ada", new(big.Int).Div(num, Ada)) } return fmt.Sprintf("%v Wei", num) diff --git a/ethutil/common_test.go b/ethutil/common_test.go index 8031f08ab..2667eaf3a 100644 --- a/ethutil/common_test.go +++ b/ethutil/common_test.go @@ -26,15 +26,15 @@ func TestCommon(t *testing.T) { t.Error("Got", szabo) } - if vito != "10 Vita" { + if vito != "10 Shannon" { t.Error("Got", vito) } - if turing != "10 Turing" { + if turing != "10 Babbage" { t.Error("Got", turing) } - if eins != "10 Eins" { + if eins != "10 Ada" { t.Error("Got", eins) } diff --git a/ethutil/config.go b/ethutil/config.go index b4bd9158e..abe86babe 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -9,14 +9,6 @@ import ( "runtime" ) -// Log types available -type LogType byte - -const ( - LogTypeStdIn = 1 - LogTypeFile = 2 -) - // Config struct type config struct { Db Database @@ -34,7 +26,7 @@ var Config *config // Read config // // Initialize the global Config variable with default settings -func ReadConfig(base string) *config { +func ReadConfig(base string, logTypes LoggerType) *config { if Config == nil { usr, _ := user.Current() path := path.Join(usr.HomeDir, base) @@ -50,8 +42,8 @@ func ReadConfig(base string) *config { } } - Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC6"} - Config.Log = NewLogger(LogFile|LogStd, LogLevelDebug) + Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC7"} + Config.Log = NewLogger(logTypes, LogLevelDebug) Config.SetClientString("/Ethereum(G)") } @@ -138,7 +130,6 @@ func (log *Logger) Infoln(v ...interface{}) { return } - //fmt.Println(len(log.logSys)) for _, logger := range log.logSys { logger.Println(v...) } @@ -153,3 +144,15 @@ func (log *Logger) Infof(format string, v ...interface{}) { logger.Printf(format, v...) } } + +func (log *Logger) Fatal(v ...interface{}) { + if log.logLevel > LogLevelInfo { + return + } + + for _, logger := range log.logSys { + logger.Println(v...) + } + + os.Exit(1) +} diff --git a/ethutil/reactor.go b/ethutil/reactor.go index f8084986c..7cf145245 100644 --- a/ethutil/reactor.go +++ b/ethutil/reactor.go @@ -46,6 +46,7 @@ func (e *ReactorEvent) Remove(ch chan React) { // Basic reactor resource type React struct { Resource interface{} + Event string } // The reactor basic engine. Acts as bridge @@ -81,6 +82,6 @@ func (reactor *ReactorEngine) Unsubscribe(event string, ch chan React) { func (reactor *ReactorEngine) Post(event string, resource interface{}) { ev := reactor.patterns[event] if ev != nil { - ev.Post(React{Resource: resource}) + ev.Post(React{Resource: resource, Event: event}) } } |