aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-07-04 00:35:48 +0800
committerzelig <viktor.tron@gmail.com>2014-07-04 00:35:48 +0800
commita3c482351114404a4568f4b3f4503182402dc6fd (patch)
tree3fb9e2fa5e12ba662d19b9ddacdbdc4869effaff /ethereal
parenta0dd1ebb6d7b449982602c796172405e7946581c (diff)
downloadgo-tangerine-a3c482351114404a4568f4b3f4503182402dc6fd.tar.gz
go-tangerine-a3c482351114404a4568f4b3f4503182402dc6fd.tar.zst
go-tangerine-a3c482351114404a4568f4b3f4503182402dc6fd.zip
Gui saves custom client id and loglevel
- gui NewWindow takes SimpleClientIdentity as argument - gui NewWindow takes ethutil.ConfigManager as argument to manage flag persistence - gui now saves loglevel and custom client id via config.Save - rename custom client id methods consistently also in wallet.qml - clientIdentifier now set in main wrappers - version handled within wrapper - modify InitConfig now returning *ethutil.ConfigManager (passed to gui)
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/assets/qml/wallet.qml4
-rw-r--r--ethereal/gui.go28
2 files changed, 17 insertions, 15 deletions
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 628d9f96a..4b252f200 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -248,9 +248,9 @@ ApplicationWindow {
text: "Client ID"
}
TextField {
- text: eth.clientId()
+ text: eth.getCustomIdentifier()
onTextChanged: {
- eth.changeClientId(text)
+ eth.setCustomIdentifier(text)
}
}
}
diff --git a/ethereal/gui.go b/ethereal/gui.go
index 1719d41b2..9f28045f8 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -9,6 +9,7 @@ import (
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
@@ -36,11 +37,13 @@ type Gui struct {
logLevel ethlog.LogLevel
open bool
- Session string
+ Session string
+ clientIdentity *ethwire.SimpleClientIdentity
+ config *ethutil.ConfigManager
}
// Create GUI, but doesn't start it
-func NewWindow(ethereum *eth.Ethereum, session string, logLevel int) *Gui {
+func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIdentity *ethwire.SimpleClientIdentity, session string, logLevel int) *Gui {
db, err := ethdb.NewLDBDatabase("tx_database")
if err != nil {
panic(err)
@@ -48,11 +51,10 @@ func NewWindow(ethereum *eth.Ethereum, session string, logLevel int) *Gui {
pub := ethpub.NewPEthereum(ethereum)
- return &Gui{eth: ethereum, txDb: db, pub: pub, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false}
+ return &Gui{eth: ethereum, txDb: db, pub: pub, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config}
}
func (gui *Gui) Start(assetPath string) {
- const version = "0.5.16"
defer gui.txDb.Close()
@@ -65,8 +67,6 @@ func (gui *Gui) Start(assetPath string) {
Init: func(p *ethpub.KeyVal, obj qml.Object) { p.Key = ""; p.Value = "" },
}})
- ethutil.Config.SetClientString("Ethereal")
-
// Create a new QML engine
gui.engine = qml.NewEngine()
context := gui.engine.Context()
@@ -103,14 +103,14 @@ func (gui *Gui) Start(assetPath string) {
ethlog.AddLogSystem(gui)
}
win.Wait()
- // need to silence gui logger after window closed otherwise logsystem hangs
- gui.SetLogLevel(ethlog.Silence)
+ // need to silence gui logger after window closed otherwise logsystem hangs (but do not save loglevel)
+ gui.logLevel = ethlog.Silence
gui.open = false
}
func (gui *Gui) Stop() {
if gui.open {
- gui.SetLogLevel(ethlog.Silence)
+ gui.logLevel = ethlog.Silence
gui.open = false
gui.win.Hide()
}
@@ -369,17 +369,19 @@ func (gui *Gui) Create(recipient, value, gas, gasPrice, data string) (*ethpub.PR
return gui.pub.Transact(gui.privateKey(), recipient, value, gas, gasPrice, data)
}
-func (gui *Gui) ChangeClientId(id string) {
- ethutil.Config.SetIdentifier(id)
+func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
+ gui.clientIdentity.SetCustomIdentifier(customIdentifier)
+ gui.config.Save("id", customIdentifier)
}
-func (gui *Gui) ClientId() string {
- return ethutil.Config.Identifier
+func (gui *Gui) GetCustomIdentifier() string {
+ return gui.clientIdentity.GetCustomIdentifier()
}
// functions that allow Gui to implement interface ethlog.LogSystem
func (gui *Gui) SetLogLevel(level ethlog.LogLevel) {
gui.logLevel = level
+ gui.config.Save("loglevel", level)
}
func (gui *Gui) GetLogLevel() ethlog.LogLevel {