forked from cerc-io/plugeth
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)
This commit is contained in:
parent
a0dd1ebb6d
commit
a3c4823511
@ -248,9 +248,9 @@ ApplicationWindow {
|
|||||||
text: "Client ID"
|
text: "Client ID"
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: eth.clientId()
|
text: eth.getCustomIdentifier()
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
eth.changeClientId(text)
|
eth.setCustomIdentifier(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethlog"
|
"github.com/ethereum/eth-go/ethlog"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
|
"github.com/ethereum/eth-go/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -36,11 +37,13 @@ type Gui struct {
|
|||||||
logLevel ethlog.LogLevel
|
logLevel ethlog.LogLevel
|
||||||
open bool
|
open bool
|
||||||
|
|
||||||
Session string
|
Session string
|
||||||
|
clientIdentity *ethwire.SimpleClientIdentity
|
||||||
|
config *ethutil.ConfigManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create GUI, but doesn't start it
|
// 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")
|
db, err := ethdb.NewLDBDatabase("tx_database")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -48,11 +51,10 @@ func NewWindow(ethereum *eth.Ethereum, session string, logLevel int) *Gui {
|
|||||||
|
|
||||||
pub := ethpub.NewPEthereum(ethereum)
|
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) {
|
func (gui *Gui) Start(assetPath string) {
|
||||||
const version = "0.5.16"
|
|
||||||
|
|
||||||
defer gui.txDb.Close()
|
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 = "" },
|
Init: func(p *ethpub.KeyVal, obj qml.Object) { p.Key = ""; p.Value = "" },
|
||||||
}})
|
}})
|
||||||
|
|
||||||
ethutil.Config.SetClientString("Ethereal")
|
|
||||||
|
|
||||||
// Create a new QML engine
|
// Create a new QML engine
|
||||||
gui.engine = qml.NewEngine()
|
gui.engine = qml.NewEngine()
|
||||||
context := gui.engine.Context()
|
context := gui.engine.Context()
|
||||||
@ -103,14 +103,14 @@ func (gui *Gui) Start(assetPath string) {
|
|||||||
ethlog.AddLogSystem(gui)
|
ethlog.AddLogSystem(gui)
|
||||||
}
|
}
|
||||||
win.Wait()
|
win.Wait()
|
||||||
// need to silence gui logger after window closed otherwise logsystem hangs
|
// need to silence gui logger after window closed otherwise logsystem hangs (but do not save loglevel)
|
||||||
gui.SetLogLevel(ethlog.Silence)
|
gui.logLevel = ethlog.Silence
|
||||||
gui.open = false
|
gui.open = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) Stop() {
|
func (gui *Gui) Stop() {
|
||||||
if gui.open {
|
if gui.open {
|
||||||
gui.SetLogLevel(ethlog.Silence)
|
gui.logLevel = ethlog.Silence
|
||||||
gui.open = false
|
gui.open = false
|
||||||
gui.win.Hide()
|
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)
|
return gui.pub.Transact(gui.privateKey(), recipient, value, gas, gasPrice, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) ChangeClientId(id string) {
|
func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
|
||||||
ethutil.Config.SetIdentifier(id)
|
gui.clientIdentity.SetCustomIdentifier(customIdentifier)
|
||||||
|
gui.config.Save("id", customIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) ClientId() string {
|
func (gui *Gui) GetCustomIdentifier() string {
|
||||||
return ethutil.Config.Identifier
|
return gui.clientIdentity.GetCustomIdentifier()
|
||||||
}
|
}
|
||||||
|
|
||||||
// functions that allow Gui to implement interface ethlog.LogSystem
|
// functions that allow Gui to implement interface ethlog.LogSystem
|
||||||
func (gui *Gui) SetLogLevel(level ethlog.LogLevel) {
|
func (gui *Gui) SetLogLevel(level ethlog.LogLevel) {
|
||||||
gui.logLevel = level
|
gui.logLevel = level
|
||||||
|
gui.config.Save("loglevel", level)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) GetLogLevel() ethlog.LogLevel {
|
func (gui *Gui) GetLogLevel() ethlog.LogLevel {
|
||||||
|
Loading…
Reference in New Issue
Block a user