merge jsonrpc
This commit is contained in:
@ -41,6 +41,7 @@ var (
|
||||
StartRpc bool
|
||||
StartWebSockets bool
|
||||
RpcPort int
|
||||
WsPort int
|
||||
NatType string
|
||||
PMPGateway string
|
||||
OutboundPort string
|
||||
@ -96,6 +97,7 @@ func Init() {
|
||||
flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for PMP")
|
||||
flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers")
|
||||
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
|
||||
flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on")
|
||||
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
|
||||
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
|
||||
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
|
||||
|
@ -131,7 +131,7 @@ func main() {
|
||||
}
|
||||
|
||||
if StartWebSockets {
|
||||
utils.StartWebSockets(ethereum)
|
||||
utils.StartWebSockets(ethereum, WsPort)
|
||||
}
|
||||
|
||||
utils.StartEthereum(ethereum, UseSeed)
|
||||
|
@ -47,7 +47,6 @@ ApplicationWindow {
|
||||
|
||||
console.log("starting browser")
|
||||
newBrowserTab("http://etherian.io");
|
||||
console.log("done")
|
||||
|
||||
// Command setup
|
||||
gui.sendCommand(0)
|
||||
|
@ -28,7 +28,7 @@ Rectangle {
|
||||
text: "Address"
|
||||
}
|
||||
TextField {
|
||||
text: eth.key().address
|
||||
text: ""//eth.key().address
|
||||
width: 500
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@ Rectangle {
|
||||
function setBalance() {
|
||||
//balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address))
|
||||
if(menuItem)
|
||||
menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address))
|
||||
menuItem.secondaryTitle = eth.numberToHuman("0")
|
||||
//menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address))
|
||||
}
|
||||
|
||||
ListModel {
|
||||
@ -155,16 +156,6 @@ Rectangle {
|
||||
model: ListModel {
|
||||
id: txModel
|
||||
Component.onCompleted: {
|
||||
/*
|
||||
var me = eth.key().address;
|
||||
var filterTo = ethx.watch({latest: -1, to: me});
|
||||
var filterFrom = ethx.watch({latest: -1, from: me});
|
||||
filterTo.changed(addTxs)
|
||||
filterFrom.changed(addTxs)
|
||||
|
||||
addTxs(filterTo.messages())
|
||||
addTxs(filterFrom.messages())
|
||||
*/
|
||||
}
|
||||
|
||||
function addTxs(messages) {
|
||||
|
@ -43,6 +43,7 @@ var (
|
||||
StartRpc bool
|
||||
StartWebSockets bool
|
||||
RpcPort int
|
||||
WsPort int
|
||||
UseUPnP bool
|
||||
NatType string
|
||||
OutboundPort string
|
||||
@ -111,6 +112,7 @@ func Init() {
|
||||
flag.BoolVar(&UseUPnP, "upnp", true, "enable UPnP support")
|
||||
flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers")
|
||||
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
|
||||
flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on")
|
||||
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
|
||||
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
|
||||
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
|
||||
|
@ -32,7 +32,6 @@ import (
|
||||
"path"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@ -229,41 +228,44 @@ func (gui *Gui) setInitialChain(ancientBlocks bool) {
|
||||
}
|
||||
|
||||
func (gui *Gui) loadAddressBook() {
|
||||
view := gui.getObjectByName("infoView")
|
||||
nameReg := gui.xeth.World().Config().Get("NameReg")
|
||||
if nameReg != nil {
|
||||
it := nameReg.Trie().Iterator()
|
||||
for it.Next() {
|
||||
if it.Key[0] != 0 {
|
||||
view.Call("addAddress", struct{ Name, Address string }{string(it.Key), ethutil.Bytes2Hex(it.Value)})
|
||||
}
|
||||
/*
|
||||
view := gui.getObjectByName("infoView")
|
||||
nameReg := gui.xeth.World().Config().Get("NameReg")
|
||||
if nameReg != nil {
|
||||
it := nameReg.Trie().Iterator()
|
||||
for it.Next() {
|
||||
if it.Key[0] != 0 {
|
||||
view.Call("addAddress", struct{ Name, Address string }{string(it.Key), ethutil.Bytes2Hex(it.Value)})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (self *Gui) loadMergedMiningOptions() {
|
||||
view := self.getObjectByName("mergedMiningModel")
|
||||
/*
|
||||
view := self.getObjectByName("mergedMiningModel")
|
||||
|
||||
mergeMining := self.xeth.World().Config().Get("MergeMining")
|
||||
if mergeMining != nil {
|
||||
i := 0
|
||||
it := mergeMining.Trie().Iterator()
|
||||
for it.Next() {
|
||||
view.Call("addMergedMiningOption", struct {
|
||||
Checked bool
|
||||
Name, Address string
|
||||
Id, ItemId int
|
||||
}{false, string(it.Key), ethutil.Bytes2Hex(it.Value), 0, i})
|
||||
mergeMining := self.xeth.World().Config().Get("MergeMining")
|
||||
if mergeMining != nil {
|
||||
i := 0
|
||||
it := mergeMining.Trie().Iterator()
|
||||
for it.Next() {
|
||||
view.Call("addMergedMiningOption", struct {
|
||||
Checked bool
|
||||
Name, Address string
|
||||
Id, ItemId int
|
||||
}{false, string(it.Key), ethutil.Bytes2Hex(it.Value), 0, i})
|
||||
|
||||
i++
|
||||
i++
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
|
||||
nameReg := gui.xeth.World().Config().Get("NameReg")
|
||||
addr := gui.address()
|
||||
|
||||
var inout string
|
||||
@ -275,31 +277,11 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
|
||||
|
||||
var (
|
||||
ptx = xeth.NewJSTx(tx)
|
||||
send = nameReg.Storage(tx.From())
|
||||
rec = nameReg.Storage(tx.To())
|
||||
s, r string
|
||||
send = ethutil.Bytes2Hex(tx.From())
|
||||
rec = ethutil.Bytes2Hex(tx.To())
|
||||
)
|
||||
|
||||
if core.MessageCreatesContract(tx) {
|
||||
rec = nameReg.Storage(core.AddressFromMessage(tx))
|
||||
}
|
||||
|
||||
if send.Len() != 0 {
|
||||
s = strings.Trim(send.Str(), "\x00")
|
||||
} else {
|
||||
s = ethutil.Bytes2Hex(tx.From())
|
||||
}
|
||||
if rec.Len() != 0 {
|
||||
r = strings.Trim(rec.Str(), "\x00")
|
||||
} else {
|
||||
if core.MessageCreatesContract(tx) {
|
||||
r = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
|
||||
} else {
|
||||
r = ethutil.Bytes2Hex(tx.To())
|
||||
}
|
||||
}
|
||||
ptx.Sender = s
|
||||
ptx.Address = r
|
||||
ptx.Sender = send
|
||||
ptx.Address = rec
|
||||
|
||||
if window == "post" {
|
||||
//gui.getObjectByName("transactionView").Call("addTx", ptx, inout)
|
||||
@ -320,7 +302,7 @@ func (gui *Gui) readPreviousTransactions() {
|
||||
}
|
||||
|
||||
func (gui *Gui) processBlock(block *types.Block, initial bool) {
|
||||
name := strings.Trim(gui.xeth.World().Config().Get("NameReg").Storage(block.Coinbase()).Str(), "\x00")
|
||||
name := ethutil.Bytes2Hex(block.Coinbase())
|
||||
b := xeth.NewJSBlock(block)
|
||||
b.Name = name
|
||||
|
||||
@ -523,9 +505,9 @@ NumGC: %d
|
||||
func (gui *Gui) setPeerInfo() {
|
||||
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
||||
gui.win.Root().Call("resetPeers")
|
||||
for _, peer := range gui.xeth.Peers() {
|
||||
gui.win.Root().Call("addPeer", peer)
|
||||
}
|
||||
//for _, peer := range gui.xeth.Peers() {
|
||||
//gui.win.Root().Call("addPeer", peer)
|
||||
//}
|
||||
}
|
||||
|
||||
func (gui *Gui) privateKey() string {
|
||||
|
@ -73,7 +73,7 @@ func run() error {
|
||||
}
|
||||
|
||||
if StartWebSockets {
|
||||
utils.StartWebSockets(ethereum)
|
||||
utils.StartWebSockets(ethereum, WsPort)
|
||||
}
|
||||
|
||||
gui := NewWindow(ethereum, config, ethereum.ClientIdentity().(*p2p.SimpleClientIdentity), KeyRing, LogLevel)
|
||||
|
@ -21,15 +21,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/event/filter"
|
||||
@ -77,56 +73,6 @@ func (self *UiLib) Notef(args []interface{}) {
|
||||
guilogger.Infoln(args...)
|
||||
}
|
||||
|
||||
func (self *UiLib) LookupDomain(domain string) string {
|
||||
world := self.World()
|
||||
|
||||
if len(domain) > 32 {
|
||||
domain = string(crypto.Sha3([]byte(domain)))
|
||||
}
|
||||
data := world.Config().Get("DnsReg").StorageString(domain).Bytes()
|
||||
|
||||
// Left padded = A record, Right padded = CNAME
|
||||
if len(data) > 0 && data[0] == 0 {
|
||||
data = bytes.TrimLeft(data, "\x00")
|
||||
var ipSlice []string
|
||||
for _, d := range data {
|
||||
ipSlice = append(ipSlice, strconv.Itoa(int(d)))
|
||||
}
|
||||
|
||||
return strings.Join(ipSlice, ".")
|
||||
} else {
|
||||
data = bytes.TrimRight(data, "\x00")
|
||||
|
||||
return string(data)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UiLib) LookupName(addr string) string {
|
||||
var (
|
||||
nameReg = self.World().Config().Get("NameReg")
|
||||
lookup = nameReg.Storage(ethutil.Hex2Bytes(addr))
|
||||
)
|
||||
|
||||
if lookup.Len() != 0 {
|
||||
return strings.Trim(lookup.Str(), "\x00")
|
||||
}
|
||||
|
||||
return addr
|
||||
}
|
||||
|
||||
func (self *UiLib) LookupAddress(name string) string {
|
||||
var (
|
||||
nameReg = self.World().Config().Get("NameReg")
|
||||
lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32))
|
||||
)
|
||||
|
||||
if lookup.Len() != 0 {
|
||||
return ethutil.Bytes2Hex(lookup.Bytes())
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *UiLib) PastPeers() *ethutil.List {
|
||||
return ethutil.NewList([]string{})
|
||||
//return ethutil.NewList(eth.PastPeers())
|
||||
|
@ -38,9 +38,10 @@ import (
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
rpchttp "github.com/ethereum/go-ethereum/rpc/http"
|
||||
rpcws "github.com/ethereum/go-ethereum/rpc/ws"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/websocket"
|
||||
// "github.com/ethereum/go-ethereum/websocket"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
)
|
||||
|
||||
@ -193,7 +194,7 @@ func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, Secre
|
||||
|
||||
func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
|
||||
var err error
|
||||
ethereum.RpcServer, err = rpc.NewJsonRpcServer(xeth.NewJSXEth(ethereum), RpcPort)
|
||||
ethereum.RpcServer, err = rpchttp.NewRpcHttpServer(xeth.NewJSXEth(ethereum), RpcPort)
|
||||
if err != nil {
|
||||
clilogger.Errorf("Could not start RPC interface (port %v): %v", RpcPort, err)
|
||||
} else {
|
||||
@ -201,11 +202,18 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
|
||||
}
|
||||
}
|
||||
|
||||
func StartWebSockets(eth *eth.Ethereum) {
|
||||
func StartWebSockets(eth *eth.Ethereum, wsPort int) {
|
||||
clilogger.Infoln("Starting WebSockets")
|
||||
|
||||
sock := websocket.NewWebSocketServer(eth)
|
||||
go sock.Serv()
|
||||
// sock := websocket.NewWebSocketServer(eth)
|
||||
// go sock.Serv()
|
||||
var err error
|
||||
eth.WsServer, err = rpcws.NewWebSocketServer(eth, wsPort)
|
||||
if err != nil {
|
||||
clilogger.Errorf("Could not start RPC interface (port %v): %v", wsPort, err)
|
||||
} else {
|
||||
go eth.WsServer.Start()
|
||||
}
|
||||
}
|
||||
|
||||
var gminer *miner.Miner
|
||||
|
Reference in New Issue
Block a user