cmd/ethereum, cmd/mist, core, eth, javascript, xeth: fixes for new p2p API
This commit is contained in:
@ -31,6 +31,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
)
|
||||
|
||||
@ -61,13 +62,11 @@ func main() {
|
||||
utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
|
||||
|
||||
ethereum, err := eth.New(ð.Config{
|
||||
Name: ClientIdentifier,
|
||||
Version: Version,
|
||||
Name: p2p.MakeName(ClientIdentifier, Version),
|
||||
KeyStore: KeyStore,
|
||||
DataDir: Datadir,
|
||||
LogFile: LogFile,
|
||||
LogLevel: LogLevel,
|
||||
Identifier: Identifier,
|
||||
MaxPeers: MaxPeer,
|
||||
Port: OutboundPort,
|
||||
NATType: PMPGateway,
|
||||
|
@ -844,6 +844,7 @@ ApplicationWindow {
|
||||
minimumHeight: 50
|
||||
title: "Connect to peer"
|
||||
|
||||
|
||||
ComboBox {
|
||||
id: addrField
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@ -872,6 +873,17 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: nodeidField
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.right: addPeerButton.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
|
||||
editable: true
|
||||
}
|
||||
|
||||
Button {
|
||||
id: addPeerButton
|
||||
anchors.right: parent.right
|
||||
@ -879,7 +891,7 @@ ApplicationWindow {
|
||||
anchors.rightMargin: 10
|
||||
text: "Add"
|
||||
onClicked: {
|
||||
eth.connectToPeer(addrField.currentText)
|
||||
eth.connectToPeer(addrField.currentText, nodeidField.currentText)
|
||||
addPeerWin.visible = false
|
||||
}
|
||||
}
|
||||
|
@ -32,18 +32,6 @@ Rectangle {
|
||||
width: 500
|
||||
}
|
||||
|
||||
Label {
|
||||
text: "Client ID"
|
||||
}
|
||||
TextField {
|
||||
text: gui.getCustomIdentifier()
|
||||
width: 500
|
||||
placeholderText: "Anonymous"
|
||||
onTextChanged: {
|
||||
gui.setCustomIdentifier(text)
|
||||
}
|
||||
}
|
||||
|
||||
TextArea {
|
||||
objectName: "statsPane"
|
||||
width: parent.width
|
||||
|
@ -64,15 +64,6 @@ func (gui *Gui) Transact(recipient, value, gas, gasPrice, d string) (string, err
|
||||
return gui.xeth.Transact(recipient, value, gas, gasPrice, data)
|
||||
}
|
||||
|
||||
func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
|
||||
gui.clientIdentity.SetCustomIdentifier(customIdentifier)
|
||||
gui.config.Save("id", customIdentifier)
|
||||
}
|
||||
|
||||
func (gui *Gui) GetCustomIdentifier() string {
|
||||
return gui.clientIdentity.GetCustomIdentifier()
|
||||
}
|
||||
|
||||
// functions that allow Gui to implement interface guilogger.LogSystem
|
||||
func (gui *Gui) SetLogLevel(level logger.LogLevel) {
|
||||
gui.logLevel = level
|
||||
|
@ -41,7 +41,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/ui/qt/qwhisper"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
"github.com/obscuren/qml"
|
||||
@ -77,9 +76,8 @@ type Gui struct {
|
||||
|
||||
xeth *xeth.XEth
|
||||
|
||||
Session string
|
||||
clientIdentity *p2p.SimpleClientIdentity
|
||||
config *ethutil.ConfigManager
|
||||
Session string
|
||||
config *ethutil.ConfigManager
|
||||
|
||||
plugins map[string]plugin
|
||||
|
||||
@ -87,7 +85,7 @@ type Gui struct {
|
||||
}
|
||||
|
||||
// Create GUI, but doesn't start it
|
||||
func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIdentity *p2p.SimpleClientIdentity, session string, logLevel int) *Gui {
|
||||
func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, session string, logLevel int) *Gui {
|
||||
db, err := ethdb.NewLDBDatabase("tx_database")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -95,15 +93,14 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
|
||||
|
||||
xeth := xeth.New(ethereum)
|
||||
gui := &Gui{eth: ethereum,
|
||||
txDb: db,
|
||||
xeth: xeth,
|
||||
logLevel: logger.LogLevel(logLevel),
|
||||
Session: session,
|
||||
open: false,
|
||||
clientIdentity: clientIdentity,
|
||||
config: config,
|
||||
plugins: make(map[string]plugin),
|
||||
serviceEvents: make(chan ServEv, 1),
|
||||
txDb: db,
|
||||
xeth: xeth,
|
||||
logLevel: logger.LogLevel(logLevel),
|
||||
Session: session,
|
||||
open: false,
|
||||
config: config,
|
||||
plugins: make(map[string]plugin),
|
||||
serviceEvents: make(chan ServEv, 1),
|
||||
}
|
||||
data, _ := ethutil.ReadAllFile(path.Join(ethutil.Config.ExecPath, "plugins.json"))
|
||||
json.Unmarshal([]byte(data), &gui.plugins)
|
||||
|
@ -52,13 +52,11 @@ func run() error {
|
||||
config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
|
||||
|
||||
ethereum, err := eth.New(ð.Config{
|
||||
Name: ClientIdentifier,
|
||||
Version: Version,
|
||||
Name: p2p.MakeName(ClientIdentifier, Version),
|
||||
KeyStore: KeyStore,
|
||||
DataDir: Datadir,
|
||||
LogFile: LogFile,
|
||||
LogLevel: LogLevel,
|
||||
Identifier: Identifier,
|
||||
MaxPeers: MaxPeer,
|
||||
Port: OutboundPort,
|
||||
NATType: PMPGateway,
|
||||
@ -79,7 +77,7 @@ func run() error {
|
||||
utils.StartWebSockets(ethereum, WsPort)
|
||||
}
|
||||
|
||||
gui := NewWindow(ethereum, config, ethereum.ClientIdentity().(*p2p.SimpleClientIdentity), KeyRing, LogLevel)
|
||||
gui := NewWindow(ethereum, config, KeyRing, LogLevel)
|
||||
|
||||
utils.RegisterInterrupt(func(os.Signal) {
|
||||
gui.Stop()
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/event/filter"
|
||||
"github.com/ethereum/go-ethereum/javascript"
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
"github.com/obscuren/qml"
|
||||
)
|
||||
@ -142,8 +143,13 @@ func (ui *UiLib) Connect(button qml.Object) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *UiLib) ConnectToPeer(addr string) {
|
||||
if err := ui.eth.SuggestPeer(addr); err != nil {
|
||||
func (ui *UiLib) ConnectToPeer(addr string, hexid string) {
|
||||
id, err := discover.HexID(hexid)
|
||||
if err != nil {
|
||||
guilogger.Errorf("bad node ID: %v", err)
|
||||
return
|
||||
}
|
||||
if err := ui.eth.SuggestPeer(addr, id); err != nil {
|
||||
guilogger.Infoln(err)
|
||||
}
|
||||
}
|
||||
|
@ -122,12 +122,10 @@ func exit(err error) {
|
||||
}
|
||||
|
||||
func StartEthereum(ethereum *eth.Ethereum, SeedNode string) {
|
||||
clilogger.Infof("Starting %s", ethereum.ClientIdentity())
|
||||
err := ethereum.Start(SeedNode)
|
||||
if err != nil {
|
||||
clilogger.Infoln("Starting ", ethereum.Name())
|
||||
if err := ethereum.Start(SeedNode); err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
||||
RegisterInterrupt(func(sig os.Signal) {
|
||||
ethereum.Stop()
|
||||
logger.Flush()
|
||||
|
Reference in New Issue
Block a user