Merge branch 'ethersphere-feature/clientid' into develop
This commit is contained in:
commit
24ff81d14e
@ -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 {
|
||||||
|
@ -8,6 +8,11 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ClientIdentifier = "Ethereal"
|
||||||
|
Version = "0.5.16"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Leave QT on top at ALL times. Qt Needs to be initialized from the main thread
|
// Leave QT on top at ALL times. Qt Needs to be initialized from the main thread
|
||||||
qml.Init(nil)
|
qml.Init(nil)
|
||||||
@ -23,7 +28,8 @@ func main() {
|
|||||||
|
|
||||||
// precedence: code-internal flag default < config file < environment variables < command line
|
// precedence: code-internal flag default < config file < environment variables < command line
|
||||||
Init() // parsing command line
|
Init() // parsing command line
|
||||||
utils.InitConfig(ConfigFile, Datadir, Identifier, "ETH")
|
|
||||||
|
config := utils.InitConfig(ConfigFile, Datadir, "ETH")
|
||||||
|
|
||||||
utils.InitDataDir(Datadir)
|
utils.InitDataDir(Datadir)
|
||||||
|
|
||||||
@ -36,7 +42,9 @@ func main() {
|
|||||||
// create, import, export keys
|
// create, import, export keys
|
||||||
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
||||||
|
|
||||||
ethereum := utils.NewEthereum(db, keyManager, UseUPnP, OutboundPort, MaxPeer)
|
clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier)
|
||||||
|
|
||||||
|
ethereum := utils.NewEthereum(db, clientIdentity, keyManager, UseUPnP, OutboundPort, MaxPeer)
|
||||||
|
|
||||||
if ShowGenesis {
|
if ShowGenesis {
|
||||||
utils.ShowGenesis(ethereum)
|
utils.ShowGenesis(ethereum)
|
||||||
@ -46,7 +54,7 @@ func main() {
|
|||||||
utils.StartRpc(ethereum, RpcPort)
|
utils.StartRpc(ethereum, RpcPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
gui := NewWindow(ethereum, KeyRing, LogLevel)
|
gui := NewWindow(ethereum, config, clientIdentity, KeyRing, LogLevel)
|
||||||
|
|
||||||
utils.RegisterInterrupt(func(os.Signal) {
|
utils.RegisterInterrupt(func(os.Signal) {
|
||||||
gui.Stop()
|
gui.Stop()
|
||||||
|
@ -6,6 +6,11 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ClientIdentifier = "Ethereum(G)"
|
||||||
|
Version = "0.5.16"
|
||||||
|
)
|
||||||
|
|
||||||
var logger = ethlog.NewLogger("CLI")
|
var logger = ethlog.NewLogger("CLI")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -15,7 +20,7 @@ func main() {
|
|||||||
|
|
||||||
// precedence: code-internal flag default < config file < environment variables < command line
|
// precedence: code-internal flag default < config file < environment variables < command line
|
||||||
Init() // parsing command line
|
Init() // parsing command line
|
||||||
utils.InitConfig(ConfigFile, Datadir, Identifier, "ETH")
|
utils.InitConfig(ConfigFile, Datadir, "ETH")
|
||||||
|
|
||||||
utils.InitDataDir(Datadir)
|
utils.InitDataDir(Datadir)
|
||||||
|
|
||||||
@ -28,7 +33,9 @@ func main() {
|
|||||||
// create, import, export keys
|
// create, import, export keys
|
||||||
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
||||||
|
|
||||||
ethereum := utils.NewEthereum(db, keyManager, UseUPnP, OutboundPort, MaxPeer)
|
clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier)
|
||||||
|
|
||||||
|
ethereum := utils.NewEthereum(db, clientIdentity, keyManager, UseUPnP, OutboundPort, MaxPeer)
|
||||||
|
|
||||||
if ShowGenesis {
|
if ShowGenesis {
|
||||||
utils.ShowGenesis(ethereum)
|
utils.ShowGenesis(ethereum)
|
||||||
|
15
utils/cmd.go
15
utils/cmd.go
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethrpc"
|
"github.com/ethereum/eth-go/ethrpc"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
|
"github.com/ethereum/eth-go/ethwire"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@ -98,9 +99,9 @@ func InitLogging(Datadir string, LogFile string, LogLevel int, DebugFile string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitConfig(ConfigFile string, Datadir string, Identifier string, EnvPrefix string) {
|
func InitConfig(ConfigFile string, Datadir string, EnvPrefix string) *ethutil.ConfigManager {
|
||||||
InitDataDir(Datadir)
|
InitDataDir(Datadir)
|
||||||
ethutil.ReadConfig(ConfigFile, Datadir, Identifier, EnvPrefix)
|
return ethutil.ReadConfig(ConfigFile, Datadir, EnvPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func exit(err error) {
|
func exit(err error) {
|
||||||
@ -122,8 +123,12 @@ func NewDatabase() ethutil.Database {
|
|||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthereum(db ethutil.Database, keyManager *ethcrypto.KeyManager, usePnp bool, OutboundPort string, MaxPeer int) *eth.Ethereum {
|
func NewClientIdentity(clientIdentifier, version, customIdentifier string) *ethwire.SimpleClientIdentity {
|
||||||
ethereum, err := eth.New(db, keyManager, eth.CapDefault, usePnp)
|
return ethwire.NewSimpleClientIdentity(clientIdentifier, version, customIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEthereum(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, usePnp bool, OutboundPort string, MaxPeer int) *eth.Ethereum {
|
||||||
|
ethereum, err := eth.New(db, clientIdentity, keyManager, eth.CapDefault, usePnp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatalln("eth start err:", err)
|
logger.Fatalln("eth start err:", err)
|
||||||
}
|
}
|
||||||
@ -133,7 +138,7 @@ func NewEthereum(db ethutil.Database, keyManager *ethcrypto.KeyManager, usePnp b
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StartEthereum(ethereum *eth.Ethereum, UseSeed bool) {
|
func StartEthereum(ethereum *eth.Ethereum, UseSeed bool) {
|
||||||
logger.Infof("Starting Ethereum v%s", ethutil.Config.Ver)
|
logger.Infof("Starting %s", ethereum.ClientIdentity())
|
||||||
ethereum.Start(UseSeed)
|
ethereum.Start(UseSeed)
|
||||||
RegisterInterrupt(func(sig os.Signal) {
|
RegisterInterrupt(func(sig os.Signal) {
|
||||||
ethereum.Stop()
|
ethereum.Stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user